Zend framework

From DreamHost

Jump to: navigation, search

I wanted to play around with the Zend Framework and wanted to see what the big deal was with this Model-View-Controler (MVC) thing I have heard so much about. But when I googled "zend framework tutorial dreamhost" all I found was others looking for help, and the only answers were from folks talking about other hosting companies.


The instructions provided in this article or section are considered advanced.

You are expected to be knowledgeable in the UNIX shell.
Support for these instructions is not available from DreamHost tech support.
Server changes may cause this to break. Be prepared to troubleshoot this yourself if this happens.
We seriously aren't kidding about this.

  • It is my assumption you have set up shell access to your DreamHost account and can log in via SSH.
  • It is also my assumption you know how to copy files from your local computer to your DreamHost home directory.


Contents

Step 1. Download the Zend Framework

At the time of this writing 1.11.1 is the latest
http://framework.zend.com/download/latest I got the Full Package version myself.

Step 2. Make a directory named Zend_framework

This will be a nice place to keep the file needed to "make it go" in your home directory

mkdir Zend_framework

Step 3. Upload the Zend stuff you need

When up unpack/unzip it there will be a folder named library.
Upload the "library" folder and its contents to the Zend_framework on your DreamHost account
and upload the "bin" folder and its contents to the Zend_framework folder.


Step 4. Set up a php.ini for the shell script zf.sh

It seems to me you don't need to compile your own PHP to get this to work.
All you need is a php.ini file where you can add to the include path.

For this section I "borrowed" from http://wiki.dreamhost.com/PHP.ini

 cp /etc/php5/cgi/php.ini $HOME/Zend_framework/php.ini

Now edit the php.ini file you just copied and change the "include_path" line to add a new directory. The line looks something like this:

include_path  = ".:/usr/local/lib/php:/usr/local/php5/lib/pear"

Add the full path of your Zend_framework/library directory like so:

include_path  = ".:/usr/local/lib/php:/usr/local/php5/lib/pear:/home/(YOUR_USER_NAME_HERE)/Zend_framework/library"

Step 5. Modify the zf.sh script

Go into the bin directory and make these changes to the zf.sh script.

Delete these lines:

# find php: pear first, command -v second, straight up php lastly
if test "@php_bin@" != '@'php_bin'@'; then
    PHP_BIN="@php_bin@"
elif command -v php 1>/dev/null 2>/dev/null; then
    PHP_BIN=`command -v php`
else
    PHP_BIN=php
fi

...and replace them with:

# Use DreamHost's PHP 5 binary
PHP_BIN=/usr/local/php5/bin/php

Then look at the bottom of the file for this command:

$PHP_BIN -d safe_mode=Off -f "$PHP_DIR/zf.php" -- $@

...and add a command-line switch to tell PHP where to find your custom php.ini file:

$PHP_BIN -c /home/(YOUR_USER_NAME_HERE)/Zend_framework/php.ini -d safe_mode=Off -f "$PHP_DIR/zf.php" -- $@

Save your changes.

Step 6. Chmod the zf.sh script

chmod +x $HOME/Zend_framework/bin/zf.sh

Step 7. Create an alias to the zf.sh script

  • Assuming you use the bash shell like I do:

ADD

alias zf=/home/(YOUR_USER_NAME_HERE)/Zend_framework/bin/zf.sh

to Your .bash_profile in your Home directory
then

source .bash_profile

Step 8. TEST the zf script

Type:

zf show version

You should see a response like this:

Zend Framework Version: 1.11.1

If you do not, stop, go back and check your work before proceeding.

Step 9. Set up a project

Be sure to check out http://akrabat.com/zend-framework-tutorial/
In fact, that is where I started.
However, that tutorial assumes you can edit a vhost and bounce apache.
Here is what I did instead. Do not proceed if Step 8 failed.
For sections 9.1 to 9.9, use a domain you have fully hosted with DreamHost and not actually "example.com."



9.1. Log in to https://panel.dreamhost.com/
9.2. Created a new sub-domain under "Manage Domains" (for this example: "zend.example.com")
(a DreamHost script will do its ninja magic and set up the vhost and create a directory "zend.example.com" in your $HOME directory)
9.3. Wait for it... the directory "zend.example.com" in your $HOME directory that is.
9.4. Log in via SSH and delete the directory "zend.example.com" in your $HOME directory (not in the panel, the vhost should still be set up)

9.5. From your $HOME
zf create project zend.example.com 

9.6. You should now have a “zend.example.com” again with all the Zend framework bits.

NB: You don't have to run with a custom php.ini, so as an alternative to steps 9.7 and 9.8 you can just symlink to the Zend Framework library.
cd zend.example.com/library
ln -s /home/(YOUR_USER_NAME_HERE/Zend_framework/library/Zend .
then skip ahead to step 9.9

9.7 Follow the steps on http://wiki.dreamhost.com/PHP.ini under "Custom php.ini for a Single domain" and apply the changes for your "zend.example.com" directory.
9.8 Edit the php.ini file under the cgi-bin you made in 9.7 and change line 494:

FROM include_path = ".:/usr/local/php5/lib/php:/usr/local/lib/php"

TO something like

include_path = ".:/usr/local/php5/lib/php:/usr/local/lib/php:/home/(YOUR_USER_NAME_HERE)/Zend_framework/library"


9.9 Add this to your zend.example.com/.htaccess file

Again, use your own domain name, not "example.com."

RewriteEngine on 
RewriteCond %{HTTP_HOST} zend\.example\.com [NC] 
RewriteCond %{REQUEST_URI} !/public 
RewriteRule (.*) /public/$1 [L]



Originally written by Masterwebmonkey 15:54, 24 June 2009 (UTC)

Personal tools