Setting up shop – vol. 2
To continue our excursion from last time, where we’ve installed our local server, PHP engine and MySQL database we today will install the Zend Framework on our machine. After doing that we will be very nearly done with preparations and can jump right into code-mode.
To install Zend we will first need to download it, obviously. You can head over to Zend.com on your own and search for the download link, or you can just click here. After downloading we should unpack the archive and get ready to go.
You can now choose where you would like to put your Zend Framework. Personally I like to have things that belong together in the same place, so I am going to put Zend inside my MAMP Folder (not in the htdocs however). If you prefer otherwise, that is up to you.
And actually there are not too many things left to do at this particular task. Two steps remain and the first is to tell PHP where it can find the classes of the Zend Framework. For that we will need edit the php.ini file which you should find (on a Mac) in your MAMP folder, there you’ll have to go to conf and navigate to the folder which is named just like the PHP version you are running (which most likely is the highest number available). Inside this folder you’ll find the php.ini file which you should now edit in your text editor of choice.
You’ll need to locate the line which begins with “include_path. Yours should look something like this:
include_path = “.:/Applications/MAMP/bin/php5.3/lib/php”
This line tells your webserver that the basic files where standard PHP classes are to be found is located, in this case it’s the local installation of a MAMP server, the bin folder and PHP 5.3 subfolder. Now we will add the location of the Zend Framework files to this. Afterwards your include_path should look like this:
include_path = “.:/Applications/MAMP/bin/php5.3/lib/php:/Applications/MAMP/zend/library”
Note that after the end of the first entry there is a colon (‘:’) which is the appropriate delimiter for include path entries on the Mac. (I believe Windows users need to use an semi-colon ‘;’, but I am unsure of that). Also not that you’ll have to point to the ‘library’ subfolder of the unpacked downloaded Zend Framework.
In general we could use our Zend Framework from within our webserver by now, but there is one more thing we can do to make our lives a little easier: You can interact with your Zend Framework from within your Terminal, which for example can help you to create new Zend-based projects. For that we’ll need to edit the configuration file for our bash (which is the Terminal App you’ll find in the Utilities folder on your Mac).
If this is the first time you try to adapt your Terminal the file we need doesn’t exist yet. In that case we can just create a new one. The file is to be called ‘.profile’, it is a system file so it starts with a .
The line we’ll need to add should look like this:
alias zf=/Applications/MAMP/zend/bin/zf.sh
This tells the bash that whenever we type the command zf it is supposed to execute the shell script in the specified location. To see if it works open your Terminal and type
zf show version
To see what else you can do with the zf command, just type “zf ?”
So, there we are now. A working webserver with PHP and MySQL database on our computers and the Zend Framework ready to go. Next time we’ll create our first project and play with virtual hosts a little bit.
Categorised as: Basics
[...] how to install a webserver with PHP and MySQL support on your local Mac (and PCs, too) and how to get the Zend Framework integrated into that setup. Before we’re really ready to go, however, there is one more thing to do: [...]
Thanks for the post