Monday, 7 February 2011

Zend on XAMPP on localhost on Windows

I learned to use the MVC psuedo design pattern through codeigniter. MVC seems to be commonly used through the Zend Framework. I learned PHP through a Zend course and was keen to have the Zend MVC Framework on my XAMPP localhost server. So I followed the instructions from the Zend website, which weren't great.

First of all, before you begin the tutorial from the Zend website, you already have the Zend Framework on XAMPP. It's in the PEAR directory. So you just need to replace this with an up to date version.

The other thing you need to replace is zf.bat, which lies within the php directory.

Another thing you need to do before reading the Zend instructions is edit your hosts file. Here are a couple of lines from mine:

127.0.0.1       quickstart.local
127.0.0.1 localhost


Now. Here is the crucial one. If you follow the Zend instructions to the letter, you are left with a localhost which only works with the Zend Framework. You don't want this. What about all the times you are not using Zend?
So, you need to use 2 ports for your localhost. One for Zend and one for everything else. Then you can set
up your VirtualHost entries within httpd.conf like these:


Listen 80
Listen 8080



<VirtualHost *:8080>
    ServerName quickstart.local
    DocumentRoot C:\xampp\htdocs\quickstart\public
    SetEnv APPLICATION_ENV "development"
    <Directory C:\xampp\htdocs\quickstart\public>
        DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot C:\xampp\htdocs
    SetEnv APPLICATION_ENV "development"
    <Directory C:\xampp\htdocs>
        DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
    </Directory>
</VirtualHost>

You can then go to your web browser and use :
http://quickstart.local:8080/ for Zend and
http://localhost/ for everything else.

No comments:

Post a Comment