Zend, MongoDB, Doctrine a perfect relationship 2 : Making a sample application

Installing and setup Zend framework with Mongo and Docrine in your local Linux machine

Frist of all you have to install all the requirements (prerequisites) for zend. Make sure that you have installed,

  • Latest PHP
  • Apache Http Server
  • MongoDB Server (http://docs.mongodb.org/manual/installation/)
  • php-mongo (http://www.php.net/manual/en/mongo.installation.php)
  • Git
  • These steps are related to configure zend skeleton app under Linux platform

  • change your directory path to a convenient location
  • cd /var/www/zend-test
    
  • clone the latest Zend skeleton application from github
  • $ git clone git@github.com:zendframework/ZendSkeletonApplication.git
    
  • move inside to your applicaion
  • $ cd ZendSkeletonApplication/
    
  • Inside your skelton application you can see following files are available
  • composer.json  composer.phar  config  data  init_autoloader.php  LICENSE.txt  module  public  README.md  vendor
    
  • Update and install zend framework inside your skeleton application
  • $ php composer.phar self-update
    Updating to version 3da....3ff.
        Downloading: 100% 
    	
    $ php composer.phar install
    Loading composer repositories with package information
    Installing dependencies (including require-dev)
      - Installing zendframework/zendframework (2.2.4)
        Downloading: 100% 
    	
    ....
    ....
    Writing lock file
    Generating autoload files
    
  • Mention your project dependencies in your composer.json file
  • $ vim composer.json
    "minimum-stability": "alpha",
    "require": {
    	"doctrine/doctrine-mongo-odm-module": "dev-master",
    	....
    	....
    }
    
  • Update your project with dependencies
  • $ php composer.phar update
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
      - Installing doctrine/lexer (v1.0)
        Downloading: 100%         
    
      - Installing doctrine/annotations (v1.1.2)
        Downloading: 100%         
      
    	........
    	........  
    
      - Installing doctrine/mongodb (1.0.3)
        Downloading: 100%         
    
      - Installing doctrine/mongodb-odm (1.0.0-BETA9)
                Downloading: 100% 
    
      - Installing doctrine/doctrine-module (0.7.2)
        Downloading: 100%         
    
      - Installing doctrine/doctrine-mongo-odm-module (dev-master 6d18d1f)
        Cloning 6d18d1fa915787d7adc39344d6bd987a29ca54e3
    
  • Create a virtual host for your project
  • create a file inside your /etc/sites-available/ folder named with your project(or any suitable name)

    $sudo vim /etc/sites-available/zend-mongo-test1
    <VirtualHost *:80>
        ServerName zend-mongo-test.localhost
        DocumentRoot /var/www/zend-test/ZendSkeletonApplication/public
        SetEnv APPLICATION_ENV "development"
        <Directory /var/www/zend-test/ZendSkeletonApplication/public>
            DirectoryIndex index.php
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>
    
  • create a symbolic link under /etc/sites-enabled/
  • $ sudo ln -s /etc/sites-available/zend-mongo-test1 /etc/sites-enabled/zend-mongo-test1
    $ ls -al /etc/sites-enabled
    total 8
    drwxr-xr-x 2 root root 4096 Oct  7 16:40 .
    drwxr-xr-x 7 root root 4096 Aug 15 10:48 ..
    lrwxrwxrwx 1 root root   26 Mar  1  2013 000-default -> ../sites-available/default
    lrwxrwxrwx 1 root root   45 Oct  7 16:40 zend-mongo-test1 -> /etc/apache2/sites-available/zend-mongo-test1
    
  • Restart your apache server and you can see your sample skeleton application in your browser
  • $server apache restart
    

    Browse http://zend-mongo-test.localhost