How to install Zend Framework on Windows

Answer

It seems like you're having trouble with the PATH in the Windows command shell. This is independent of Zend Framework. Understanding the PATH concept in a shell environment is a hurdle many programmers have to overcome, but once you get it, you can use it to increase your productivity.

You can always run a program from the command shell using that program's absolute path. For example:

C:\> c:\wamp\bin\php\php.exe

You can also run a command using a relative path. That is, you enter the path from your current working directory to the location of the program you want to run.

C:\> cd c:\wamp
C:\> bin\php\php.exe

But if you run a command in the command shell without naming the full path to the executable, the shell tries to find the program executable in one of the directories listed in your PATH environment variable. That is, the path is a string with directory names separated by semicolons. To run an executable, the shell tries each directory in that list, in order, as if you had

C:\> type %PATH%
C:\WINDOWS\;C:\WINDOWS\SYSTEM32
C:\> php.exe
...error that it cannot find php.exe...

Special case: running php.exe also works if your current working directory happens to be the location of that program executable. But that's just an example of using a relative path, using a path with zero directory levels.

Second problem is that you're running zf.bat which is a script that in turn invokes php.exe without specifying a path. It assumes you have added the location of php.exe to your PATH environment variable.

C:\> SET PATH=%PATH%;C:\wamp\bin\php
C:\> php.exe -v
PHP 5.3.1(cli)(built:Nov29200913:59:20)Copyright(c)1997-2009The PHP GroupZendEngine v2.3.0,Copyright(c)1998-2009ZendTechnologies

The zf.bat script itself also needs to be found. You can do this by adding the directory where it resides to your PATH. Assuming you installed Zend Framework under C:\zf, for example:

C:\> type %PATH%
C:\WINDOWS\;C:\WINDOWS\SYSTEM32;C:\wamp\bin\php
C:\> zf.bat
...error that it cannot find zf.bat...
C:\> SET PATH=%PATH%;C:\zf\bin
C:\> zf.bat show version
ZendFrameworkVersion:1.10.0dev

I would also recommend that you install Zend Framework outside your htdocs directory. There's only one PHP file you need under your htdocs: that is the single bootstrap file that Zend Framework uses to instantiate the Front Controller and dispatch the request.

When you use zf.bat to generate an skeleton application for you, it creates a directory public with a PHP script index.php inside that directory. This index.php file is the one you need to be in your htdocs directory. You also need assets like CSS, Javascript, and images to be under your htdocs. The rest of your application code, and the entire Zend Framework itself, should be outside your htdocs. Especially any config files where you store sensitive data such as your database password, etc.

You can edit the index.php file. It may define a PHP constant APPLICATION_PATH, which is the location of the rest of your application code.

<?php

defined("APPLICATION_PATH")|| define("APPLICATION_PATH", realpath(dirname(__FILE__)."/../application"));

That default definition for APPLICATION_PATH assumes that your htdocs is a sister directory to the rest of your application code generated by the zf.bat tool. You can certainly put your app code anywhere else, but you have to change the above code so that the index.php script finds it.

Also the index.php script may add the location of library code to PHP's INCLUDE_PATH. This is useful if you need to make the Zend Framework library findable, or if you use other third-party PHP code in your application. Assuming you installed Zend Framework under C:\zf, you should add its library subdirectory to your PHP INCLUDE_PATH.

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array("C:/zf/library",
    realpath(APPLICATION_PATH ."/../library"),
    get_include_path())));

The code templates generated by the zf.bat script try to make sensible default guesses about where your code is located, but your environment is your own, and it's easy to edit these scripts to specify the true location where you installed your code and libraries.

All zend-framework Questions

Ask your interview questions on zend-framework

Write Your comment or Questions if you want the answers on zend-framework from zend-framework Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---