Monday, January 3, 2011

Installing zend framework on wamp

Version Information:

WampServer 2.0i [07/11/09]
Includes :
- Apache 2.2.11
- MySQL 5.1.36
- PHP 5.3.0

Zend Framework 1.10.3

OS: windows xp sp3

Directory Structure:

c:\wamp\(out of the box wamp 2.0 structure)
c:\zend\(out of the box zend framework 1.10.3 structure)
C:\zendSites\(this is the folder i created to hold my zend projects)

-----------------------

Error 1 occurred while trying to create my project from the command prompt.
This error occurrs becuase windows does not know where to look for zf.bat.

C:\zendSites>zf create project quickstart
'zf' is not recognized as an internal or external command, operable program or batch file.

action: add the zf.bat path to windows xp environment variables...
right click mycomputer>>properties>>advanced>>environment variables>>
then highlight "path" in the list of system variables and click edit
in my case i added ";c:\zend\bin" (without quotes) to the end of the list
note that the leading semicolen is the path separator.
restart computer.

--------------------

Error 2 occurred while trying to create my project from the command prompt and after adding the zf.bat path to windows environment variables. This error occurrs because windows does not know how to execute php scripts. It needs to know the path to php.exe

C:\zendSites>zf create project quickstart
'"php.exe"' is not recognized as an internal or external command,
operable program or batch file.

action: add the php.exe path to the windows environment variables.
same as above, but this time i'm adding the path ;C:\wamp\bin\php\php5.3.0
don't forget to restart your computer

--------------------

Expanded explanation of creating a virtual host on windows running wamp server 2.0

open httpd.conf (click on the wamp icon in the services>>apache>>httpd.conf)
find and uncomment the line: #Include conf/extra/httpd-vhosts.conf by removing the # sign go to C:\wamp\bin\apache\Apache2.2.11\conf\extra\ and open httpd-vhosts.conf note the "Apache2.2.11" in the above path. obviously this is version specific.

add the following block of code to the end of httpd-vhosts.conf...


DocumentRoot "c:\zendSites\quickstart\public"
ServerName quickstart.local
SetEnv APPLICATION_ENV "development"

DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all




DocumentRoot C:\wamp\www
ServerName localhost


...after adding this block of code you will need to update your windows hosts file, which maps requested urls to the server. go to C:\WINDOWS\system32\drivers\etc and open the hosts file. add the following 2 lines to the bottom of the file...

127.0.0.1 localhost
127.0.0.1 quickstart.local

...now restart your wamp server.

notice the entries for localhost. this is to preserve localhost paths like that for phpmyadmin
note, that now you have done this your address will be quickstart.local so any reference in the tutorial that says to go to http://localhost should be replaced now by http://quickstart.local
this page will not be found by requests outside the local computer. ie. you will not be online until you register with a DNS (beyond the scope of this material)

-------------------------

Error 3
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

after making the changes above you will likely get this error In this case the error is caused becuase appache does not have the rewrite module enabled
action:
click on the wamp server icon in the services portion of the windows task bar.
apache>>apache modules>>scroll down to "rewrite_module" and click it.
wamp should restart automatically

----------------------------

Error 4
Warning: require_once(Zend/Application.php) [function.require-once]: failed to open stream: No such file or directory in C:\zendSites\quickstart\public\index.php on line 18
Fatal error: require_once() [function.require]: Failed opening required 'Zend/Application.php' (include_path='C:\zendSites\quickstart\library;.;C:\php5\pear') in C:\zendSites\quickstart\public\index.php on line 18

at this point if you have not set your include_path in php.ini you will recieve the above error.

action:
click the wamp server icon in the services section of the windows taskbar>>php>>php.ini
now change the following section...

; Windows: "\path1;\path2"
; include_path = ".;c:\php\includes"

to...

; Windows: "\path1;\path2"
include_path = ".;c:\php\includes;c:\zend\library"

...and restart the wamp server again


-----------------------------
Error 5
'dbname' is not recognized as an internal or external command,
operable program or batch file.

cmd input/output:
C:\zendSites\quickstart>zf configure db-adapter 'adapter=PDO_SQLITE&dbname=APPLICATION_PATH "/../data/db/guestbook.db"' production
A db configuration for the production section has been written to the application config file.
'dbname' is not recognized as an internal or external command,
operable program or batch file.

this has to do with the difference between how linux and windows systems intrepret quotation marks.
so you will need to change...

zf configure db-adapter 'adapter=PDO_SQLITE&dbname=APPLICATION_PATH "/../data/db/guestbook.db"' production

to...

zf configure db-adapter "adapter=PDO_SQLITE&dbname=APPLICATION_PATH '/../data/db/guestbook.db'" production

--------------------------------

when creating load.sqlite.php, data.sqlite, schema.sqlite.sql make sure that the scripts folder that holds them is at the same level as the application folder. ie. c:\zendSites\quickstart\scripts
also make sure that the load.sqlite.php code from framework.zend.com is enclosed with the php tags (). when you run this script from the prompt make sure you run it from the quickstart path

--------------------------------

Error 6
C:\zendSites\quickstart>php scripts\load.sqlite.php --withdata
PHP Warning: require_once(Zend/Loader/Autoloader.php): failed to open stream: No such file or directory in C:\zendSites\quickstart\scripts\load.sqlite.php

this was a tricky one. It occurrs when we try to run the load.sqlite.php script because the command prompt uses a different php.ini than apache. you need to navigate to...

C:\wamp\bin\php\php5.3.0\php.ini

now change the following section...

; Windows: "\path1;\path2"
; include_path = ".;c:\php\includes"

to...

; Windows: "\path1;\path2"
include_path = ".;c:\php\includes;c:\zend\library"

...and restart the wamp server again

------------------------------------

after working through all the above issues my quickstart application worked.

Good Luck!

1 comment:

  1. Zend_Controller_Front::run('controllers');
    in my index.php file is giving the following error.I foung your blog very useful,please help.

    Fatal error: Class 'Zend_Controller_Front' not found

    ReplyDelete