Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install Zend Framework on Windows

Tags:

"installing Zend Framework is so easy!!!!" yeah right...

Ok I'm working with a beginner's book and the ONE thing that is not excessively detailed is the most important part: Installing the darn thing. After browsing the quickstart guide for hours, all it said was:

"download Zend [...] add the include directory (bla bla) and YOU'RE DONE!"

right, i'm done using Zend.

Ok, not really, not yet anyway. I beg of you people, I wanna go to bed, please tell me how (in simple 6th grade detail) to install the framework. I've got the unzipped folder in my htdocs directory, and I placed zf.bat+zf.php in the htdocs root.

What's next?

thank you so much.

like image 680
Gal Avatar asked Dec 06 '09 23:12

Gal


People also ask

How do I install Zend Framework?

To install the Zend Framework, we must first install the Composer and the latest version of PHP as shown in the following steps. Install Composer − Zend uses Composer for managing its dependencies, so make sure you have the Composer installed on your machine.

Which command is used to install Zend Framework 2?

The command: composer create-project -n -sdev zendframework/skeleton-application path/to/install always create a ZendFramework 3 app is their is a command to create a project of zendfrmaework 2.


1 Answers

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: Nov 29 2009 13:59:20)  Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies 

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 Zend Framework Version: 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.

like image 129
Bill Karwin Avatar answered Oct 09 '22 17:10

Bill Karwin