nginx

Zend php framework quickstart howto (ubuntu + nginx)

Those days i've been playing with the so known and symfony competence, Zend framework, and the basic installation in ngnix.

I have to say that I love all this php frameworks, and the ruby idea of using the command line.

In ubuntu, installing zend to begin is as easy as:

sudo apt-get install zend-framework

And that's it, you have Zend installed in your machine.... don't believe me?? Create and go to /var/www/zend directory. Inside type: 

zf create project tutorial

Ready.... well, okay, not 100%, you still have to say to your server (apache or nginx in my case) where the project is.

I like to have urls for each project, as if they were living in different servers, so I added a new host in my /etc/hosts file:

127.0.1.1       zend

and, in /etc/nginx/sites-enabled/default-zend you'll finally have to add:

 

 

server {

      listen 80;

      server_name zend;

      root /var/www/zendlab/tutorial/public; ## <-- Your only path reference.

      index  index.html index.htm index.php;

        location / {

                try_files $uri $uri/ /index.php;

        }

        location ~ \.php$ {

    try_files       $uri /index.php;

    fastcgi_index   index.php;

    fastcgi_pass    127.0.0.1:9000;

    include         fastcgi_params;

    fastcgi_param   SCRIPT_FILENAME  /var/www/zendlab/tutorial/public$fastcgi_script_name;

    fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;

        }

}

 

 

And you finally can load your new Zend project from: http://zend/

Beauty solution, isn't it?

Well, we have Zend working, but it still doesn't do too much. Let's create our firs controller:

zf create action add Index

One thing which i've liked about Zend. It automatically suposes that you will use PHPUnit:

Note: PHPUnit is required in order to generate controller test stubs.