Friday, January 24, 2014

How To Set-up ZendFramework 2 for Developers from Scratch

Here are a few easy steps to bootstrap your development using Zend Framework 2.x. This assumes that you are using PHP 5.3.x or higher on a *nix machine. Was tested to work on Fedora and CentOS.

1) Install composer

(make sure you are a root user)
# sudo -i
# curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/src/
# mv /usr/local/src/composer.phar /usr/local/bin/composer

# chmod +x /usr/local/bin/composer

2) Download and install ZendFramework Skeletion Application

# composer create-project --repository-url="http://packages.zendframework.com" zendframework/skeleton-application /path/to/install/skeleton/app dev-master



3) Create your Apache virtual host (or any web server for that matter which you can easily find tutorials - search google: configure NGINX virtual host).

Add your vhost configuration file by copying the sample virtual host configuration to a vhost file. The file path may vary depending on your OS and filesystem setup.

# vim /etc/httpd/conf.d/vhosts/local.dev.ulaptech.conf

<VirtualHost *:80>
        ServerName local.dev.ulaptech.com  
        DocumentRoot /path/to/install/skeleton/app/public
        ServerAdmin root@localhost
        ErrorLog logs/dev.ulaptech.com-error_log
        CustomLog logs/dev.ulaptech.com-access_log common
        SetEnv APPLICATION_ENV local
        <Directory /path/to/install/skeleton/app>
                Order deny,allow
                Allowoverride All
        </Directory>
</VirtualHost>
# /etc/init.d/httpd configtest
If everything is in order, restart Apache
# /etc/init.d/httpd restart

4) Add entry to your local host file, so you can check the skeleton App from your browser.

# vim /etc/hosts
127.0.0.1 local.dev.ulaptech.com
<Enter.your.local.IP> local.dev.ulaptech.com

5) Check your running ZF2 skeleton Application from your browser.


6) Add your setup to you favorite SCM tool (SVN or Git)

# cd /path/to/install/skeleton/app
SVN: svn import https://your.svn.host/your/trunk -m "importing ulaptech files for the first time"
Git: git init; git commit -m "initial commit"; git add remote origin https://your.git.host/your/trunk.git; git push origin master;

7) Point your skeleton app to your favorite PHP IDE/Editor - PhpStorm, NetBeans, SublimeText, Eclipse etc.

8) Start coding :)




  • Related Links Widget for Blogspot

No comments: