PHP Command Line running, zend framework set up problem - php

Im trying to learn how to set up a Zend framework web application from scratch. Ive been using Magento and I understand how powerful Zend is, but im over my head it seems like.
So I bought a book, developing web applications with Zend 1.8 by Keith Pope, and I cant even follow past the first chapter. The thing that is confusing the hell out of me is the whole command line deal.
Here is a passage from the book --
Once we have downloaded the Zend Framework release package, we need to do some basic installation before we can start creating our application. First, create a new directory within your web server's document root, from which the application will be served. The examples in this chapter use the directory name of helloZend. Next, copy the library and bin directories from the release package into the newly created directory. The library directory contains all of the Zend Frameworks
source files, and the bin directory contains the command line interface for the
Zend Framework. The Zend Framework is now installed and ready for use!
Creating the project structure
We are now ready to start creating the directory structure for our project. In order to do this, we are going to use the command line interface provided by the Zend Framework. This interface uses the Zend_Tool component that provides a whole host of commands that makes it very easy to get up and running with the Zend Framework in just a few minutes.
In order to create the project structure, open up your command line and change into the hellozend directory, and then run the following command:
For Windows users:
bin\zf.bat create project
For Linux and Mac users:
bin/zf.sh create project
Ok so Ive done all that. But up above in first part he says upload it to your web server, did that already. But then "open up your command line", how exactly do I do this? The only command line I understand I can access is Terminal, do I do something with Terminal or??? (Im on a mac) - I tried navigating straight to bin/zf.sh on my webserver and it brought up a what do you want to open this link with, I chose terminal and nothing happened.
Can someone clarify this for me? I realize this may be a stupid question, but I have zero experience working with non live servers and what not....

I've been a ZF developer for several years, but was working on a pre- 1.5 version up until very recently (not by choice) I found it easiest to build a local version on my machine via ZendServer CE, then once all was running and stable, port it over to my dev server. Because I have full root permissions locally, I didn't run into any issues of naming/permissions as I walked through the initial tutorial of new features and initial setup.
Also, don't miss Akrabat's tutorial on getting started the ZF. It's very well written and in some cases easier to understand than the quickstart: http://akrabat.com/wp-content/uploads/Getting-Started-with-Zend-Framework.pdf

I don't say this to developers often, but you are in over your head if you don't yet understand how to open and use a command-line shell. Your question is not stupid -- everyone has to get started somewhere. But Stack Overflow is a place for specific questions about programming, like "I tried X and it didn't do what I expected, how should I code it instead?"
All I can suggest to you is to start studying. I believe that it's counter-productive to try learning new tools at the same time as trying to get a project done. So spend some time just learning the Terminal interface and how to run things in that environment.
Google for "Mac Terminal tutorial" and a bunch of useful articles and YouTube videos come up. Start there.
I also recommend "Mac OS X: The Missing Manual".
Re your comment: Okay, I think I'm seeing the source of your confusion. What the excerpt is not saying is that you need to open a shell on the host where you're developing your ZF app. What I do is to develop the project on my local host (my Macbook) so I can have quick access for moving files around and so on. This means I run an instance of Apache running on my Mac.
Then at intervals, when the app is running and done with respect to a given milestone of functionality, I upload the whole set of files I developed to my production server.
Tell me if I'm getting warmer. I really can't tell what you know and what you don't know because of the way you've asked your question.

anyone who needs the basic understanding of connecting to a webserver via terminal or command line via ssh should read the following:
http://www.elated.com/articles/ssh-and-basic-commands/
Although, the information there didn't work with my particular webhost. I had to format the connect command like this:
ssh user#host -p 1234
Where 1234 is the servers port number, which you will need to get from your webhost if you dont know it.

To run that script, navigate to directory where you've uploaded it (you open terminal, connect to your server via ssh if you're doing this remotely).
After that execute it like this:
./zf create project your_project_name
It should create new dir named "your_project_name" and in it many other sub-directories for your application.
Also, I'd recommend that you go for http://framework.zend.com/manual/en/learning.quickstart.html instead that book - Quick Start really is great.

Related

How to setup web application created in PHP (with Xampp)?

I have created an administrative system for libraries which basically lets you register books, users, borrowings and all kind of stuff that happens in a library. To code and test it, I used XAMPP, in my own PC, using Apache PHP and MySQL to structure and develop the application.
It works, and has a very complete and efficient set of functions and utilities, that is why I plan to implement it in my school's library, that for years has been using Microsoft Excel as a tool to organize all the books and students.
The thing is: I don't understand how to setup this app as a local web application. The idea is to install the folders and files in the library computer so it can control the system locally and through a browser (using localhost to access the PHP application).
I know it is possible to simply install XAMPP manually and copy the folder to htdocs and then use it normally, but I want to eliminate the manual part, and have some sort of setup that lets any person install the app without having to understand how Apache or MySQL works.
Does anybody know what could I do? I have though of creating a series of batch files (the library PC uses Windows) and move folders, create shortcuts, etc. using normal cmd commands. It would be a better alternative, but still the user would need to go through XAMPP (or some other service) setup prompts.
Thanks very much
you can create a bash file to automate this process.

"Minified" version of xampp?

I'm looking for a way to share my php applications with a colleague without using a server. My colleague isn't really versed in xampp and localhost stuff, so ideally, he shouldn't have to install or configure anything.
I'm already using SQLite to make my application more portable, but I need to figure out how to handle the php side of things. Is there a way to create a "mini" xampp or localhost that the php files can run on? Ideally, my colleague should just need to start up one program, at which point the localhost address would point to my files. Is something like that possible with xampp?
You can use ngrok. ngrok build a url for your localhost project. which you can share to your colleague or anywhere across the globe.
You can start a web server using the php executable:
php -S localhost:8000
http://php.net/manual/en/features.commandline.webserver.php
You can use Devserver. It's portable. You just have to put the Devserver folder (with your files in Local Directory) on a USB key.
It should be said that there are very, very few times where what you're talking about should be necessary. If this is a truly "personal use" case, you could just put the scripts online and set up an htaccess password for your friend. If it's software you're trying to distribute, you could create cloud access for it.
Having said that, I do have a piece of software in the wild that matches this description. The reason it needs to run its own server and be accessible locally is because it (a) runs in retail stores, (b) serves and receives data with a corporate android app only on the local network in those stores and (c) must continue to run with local data if the internet connection goes down at any given store.
The only way to do this at the moment is ship a physical mini PC stick, preloaded with XAMPP, the database, and the whole set of PHP scripts and a nice index.php file at the local root, to each and every store. In my case, this required building an internal update mechanism to push software updates as necessary. But you could probably just have your friend download a zip file with updates and replace his www root folder with it.
If you can afford $100 for a cheap PC on a stick, this is probably your best answer. It's definitely the fastest. You could wade into trying to compile your PHP code, but there is no complete solution for that.
It is actual question for me to, so I made a little research and from what I have read the most perspective way is to use a vagrant. You still will need to do a lot of configurations, but mainly on your side. Your college can deploy fairly easy and pain fry.
I found this article describing a basic workflow very useful.
Update #2: If for some reason vagrant or any other type of virtualization is not an option for you consider looking to portable xampp launcher instead

How can I get a Zend Framework project to run on IIS?

I am trying to get the Zend Framework (ver 9 Studio) to deploy and actually run on my local IIS server.
I have created a very simple little app using the built-in wizard. It works fine if I run it on the Apache server that comes with Zend. But I tried to copy the files over and run it on IIS, and I get errors.
It appears that it is missing the links to the libraries. I've tried manually isolating and grabbing the missing libraries and putting them into the /library folder. This is a good start but I still get other errors down the road.
I found a tutorial out there that comes with an example of a Zend Project that runs in IIS. But, it pretty much has the same problems as the project I created. More missing libraries. The tutorial includes some neat new tricks like a web.config that is supposed to replace the need for the .htaccess that Apache uses.
That's how far I've made it. This is all very frustrating. Does anyone have a simple example like that tutorial promised? If not, just some good information would be helpful.
you need the rewrite module, Rob Allen has a little tutorial to help. The biggest problem is usually the rewrite module, because you have to install it seperately.

WindowsAzure: Develop on deployed PHP Files

I work a lot with the WindowsAzure4E(clipse) IDE. And it's always pain to wait for the local test deployment)
Isn't there a way to develop on the deployed PHP files which must be stored somewhere to inetput or something else?
thx for your ideas.
Yes! In fact, I just got this working myself yesterday.
After installing PHP 5.3 with CGI support for IIS (making the necessary php.ini modifications of course), I simply created a new site in IIS that mapped to a role in the workspace for my Eclipse project.
Keep in mind that there's one hiccup to this and that is that the php_azure.dll file, used to access the service configuration and mount azure drives, was built to run in the azure fabric (either development or hosted). In my case, I don't NEED these features so I removed referrences to things like getconfig and poof the project loads in IIS just fine. I only need to make sure I start Azure Storage prior to launching the application.
I've been told that some folks are able to update their systems path environment variable with the location of the azure diagnostics dll (diagnostics.dll) and have it work without this modification. But this route didn't work for me. :(
I'll actually be blogging on this more this weekend as it took me a week of evenings to get things sorted out.
I found out that after the deployment the project files are copied to the folder ServiceDefinition.csx.
When you now edit the source code in this place, you can see the changes directly, without another deployment.

Can projects using PHP framework operate standalone?

I am interested in the PHP framework, especially by symfony and ZendFramework, but I am not sure of one thing: I saw the need to type command lines to create a project with these frameworks. Ok, but once the project is finished, is it possible to move files to another server without installing anything (except for Apache)?
Thank you in advance
Ps: No report, but do StackOverflow uses a framework?
It is absolutely possible to run a symfony or zend framework application without installing the framework on the server. Symfony has a special mechanism to pack everything into one folder. If you use zend framework you basically have to copy the "Zend" folder to your "lib" directory and you are ready to go.
As far as I know, StackOverflow is build on ASP.net and C# running on several windows servers.
Firstof, most of those commands are needed for development only. But also you do not have to have the commands in your global path, it's also possible to execute the scripts directly.
In case of symfony that would be something like
./symfony-framework/data/bin/symfony
if you installed symfony to symfony-framework.
I believe stackoverflow is based on .NET MVC or plain ASP .NET - http://meta.stackoverflow.com will give you that answer
With Zend Framework, it is possible. The Zend_Tool part, which sets up the basics of your project is just addition. You can, but you don't have to use it at all. You can just write the project from scratch yourself, just stick to the standard project architecture.
Anyway, once the project is ready, it does not need any command line setup, other than mayby setting correct file system permission if your project needs to write some files.
I can't say about symphony, but I assume it also can be just copied to the target server.
I don't know, how about ZF, but project made with Symfony can be easily moved to another server just by copying files. However it will be difficult to maintain your project without commands. Also you have to copy all Symfony's core files to your server, but it will be better to install Symfony there before.
About Symfony:
Usually, you develop locally on your dev environment (using Wampserver or MAMP for example). You will require access to the command line to run symfony commands, specially for complex tasks like ORM tasks. So you have to install symfony on that environment.
According to the official doc the recommended installation method is through SVN (either the trunk or a tag) inside your project folder.
When you'll push the files from your dev environment to another (using project:deploy if you can), all the required files will be pushed.
So there is no need to install (in the sense of "run" or "execute") anything on the live environment server. The only "installation" method that requires an access to the command line is the PEAR install method, which is not recommended.
The only problem that I had when I deployed an application was a user permission problem on the cache folder, but that's easy to fix by changing the folder permission.

Categories