views:

844

answers:

9

"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.

EDIT: Thanks guys for all the answers. Unfortunately I haven't been able to work with this or find a good enough resource to explain it to me in plain english. It seems that this framework adheres more so to programmers than to beginners. I've since yesterday read a little on CakePHP and found that it was incredibly easy to install and tune. As oppose to Zend Framework, where I had to dig in my "environment variables", configure "httpd.conf" and almost tie the knot between my computer driver cables to just get it running, CakePHP has already allowed me to put together a nice newbie application. In conclusion, I very much appreciate all of your help. I hope someone else venturing on ZF will be more successful with it. Thanks!

+2  A: 

The framework doesn't have to be in the htdocs folder, it can be anywhere. Once you decompressed it somewhere you're 50% done.

Next step is to locate your php.ini file (for instance create a file <?php phpinfo();?> in your htdocs folder execute it and look for "Configuration (php.ini) filepath" (or similar) in the first block. In that file add the path to the ZendFramework to the include_dir directive. This has to include the library folder. Your setting might look like this:

include_dir = .;c:\php\ZendFramework\library

Often it also includes the path to PEAR.

Then restart your server.

You are done.

johannes
ok, when i write c:\htdocs\zf.bat create project quickstartin cmd, it notifies me that "php.exe" doesn't exist. What gives??
sombe
php.ini files are not executed, they are just viewed because they are a simple text file.
tharkun
@Gal since you seem to be on Windows, add PHP to your enviroment variables to make use of the PHP CLI: http://www.rasyid.net/2008/05/11/setting-path-for-php-cli/
chelmertz
+1  A: 
  1. Zend != Zend Framework
  2. Zend Framework doesn't need to be installed. It is merely a library, it just needs to be placed somewhere.
  3. As johannes says you need to tell php where to look for the library so you add the folder where the Zend Framework library is located to your php include path.

That's it, there is nothing more!

Now it seems that your real problem has nothing to do with Zend Framework as such. You're trying to use Zend_Tool but the command line tool zf.bat is not on your system path so you are not able to use the command 'zf'. Zend Framework works fine without the tool, if you want to use it anyways, invoke the command, when you're in the folder where zf.bat resides or add the path to zf.bat to your system path.

This means in a non-vague way:

if (path-to-zf.bat isOn SYSTEM_PATH)
{
    you can call 'zf' from anywhere;
}
else
{
    you must be in the folder where zf.bat also is, if you want to call 'zf';
}
tharkun
thanks but you programmers always give such vague answers...I mean, "invoke the command, when you're in the folder where zf.bat resides or add the path to zf.bat to your system path."- please, can't you tell I'm a complete newbie?
sombe
besides, it still tells me "php.exe" file does not exist, and when i look at zf.bat i see it contains "assume php.exe is executable"
sombe
if you're a complete newbie theny I'd advise not to bother with the tool.
tharkun
which means that php.exe is also not on your system path.
tharkun
i'm very good with PHP, I just tried using Zend and all tutorials are like "super simple to install! just download and bam!"Reminds me a little bit of weight loss commercials on tv.
sombe
It is super simple. Your problem doesn't have anything to do with installing Zend Framework. Mind it, Zend Framework... not Zend.
tharkun
one last question, if I DO want to execute zf.bat on cmd, and my zf.bat file is inside the same folder with php.exe and on cmd I write:"c:\php\zf.bat" it still tells me "php.exe" is not recognized as an internal/external command. What do I do?And I understand, zend FRAMEWORK!! thanks.
sombe
You need to include php.exe on your Winows SYSTEM_PATH. And when you're at it, do it for both of them.
tharkun
A: 

Gal - I had the same problem. We must be working on the same book this weekend.

I solved the project-creation problem when I figured out that in the terminal window, you need to first navigate to the PHP home directory you created.

So in other words if you are in the PHP5 folder, type "zf create project c:/Apache/htdocs/projectname"

I had the same issue re: missing php.exe file until I figured this out.

--

That's the good news. The bad news is you're going to have similar problems when you try setting up Controllers and Actions, and my fix won't work for this. I still haven't figured this out, so I'll post again with more info and perhaps the others can help.

thank you, i'll look into that.gosh sometimes I just feel like beating these "it's so easy!" guys in the head with an inflatable rubber hammer!
sombe
I installed PHP into c:\php and it was there.
sombe
right, it was php-dist.ini, try copy/pasting it and changing the name from php-dist.ini to php.ini that worked for me
sombe
Thanks, will give it a try. Any luck with creating the new project using the workaround I suggested?
now when I write in cmd "c:\php\zf.bat" it shows a big ZF ERROR message saying I don't have Zend tool in my include_path...I mean, for real, are these guys kidding me?? I would call ZF easy as crossing the chinese wall barefoot.
sombe
here's a step-by-step:- open terminal window- type cd c:\- type cd php- type zf create project c:/APACHE/htdocs/PROJECTNAMEThat should work. Notice that you had to navigate to the PHP home directory because this is where the php.exe file is, and this is where the zf.bat and zf.php files are.
A: 

Easier to read if I type it here.

Here's a step-by-step:

  • open terminal window
  • type cd c:\
  • type cd php
  • type zf create project c:/APACHE/htdocs/PROJECTNAME

Substitute your directory and project names where I used all caps.

That should work. Notice that you had to navigate to the PHP home directory because this is where the php.exe file is, and this is where the zf.bat and zf.php files are. Apparently both are required when using Zend_Tool.

A: 

You don't say what web stack you're using, but the simplest way that I've found to work with Zend on Windows is to install Zend Core. This installs a complete stack pre-configured with the Zend Framework.

Joe Internet
+3  A: 

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.

Bill Karwin
A: 

Gal, I don't understand what do you want to do.

There is no installation or configuration for the framework. You just have to

  1. Unpack the framework anywhere
  2. Create a project running zf create "myproject"
  3. Create a shourtcut/link in /library => root folder of the framework. You can also just unpack the whole framework in this folder (/library) but if you have many projects, you will end with many copies of the framework using diskspace.
  4. change you apache configuration for opening /myproject/public/index.php when redirecting the web browser to your site.

I mean, this have nothing to do with zf, if you create a site in your computer, you have to tell Apache where is it.

You always can run zf.bat writing the whole path. If zf.bat returns un error, then very probably you have problems with you php installation.

Just in case it's helpful, this is my apache configuration (httpd.conf) for a project named zf_cms

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "C:\Users\alex\Documents\My Web Sites\zf_cms/public"
ServerName zf_cms.conexion

<Directory "C:\Users\alex\Documents\My Web Sites\zf_cms/public">
 #DirectoryIndex index.php
 AllowOverride All
 Order allow,deny
 Allow from all
</Directory>

Then you have to add this line to %windir%\system32\drivers\etc\hosts

127.0.0.1     zf_cms.conexion
Alex Angelico
A: 

I think this tutorial help for u http://www.teddyhong.com/blog/install-zend-framework-zf-command-windows

akongz
A: 
****> ****Process  of install zend framework in window 
> 1) Download zend framework
> 2)After installing xampp extract the
> Zend Framework files into a folder of
> your choice. Next step is to edit the
> php.ini. Usually this file can be
> found in the php folder in your xampp
> installation. Find the line that says
> include_path and edit the line like
> this:
>     Windows: “\path1;\path2″
>     include_path = “.;D:\Informatik\SERVER\xampp\php\pear\;D:\Informatik\SERVER\xampp\php\ZendFramework\library”
>     3) 
>      did you add your php interpreter to %PATH%?
>     In which file i have to add the PHP interpreter?
>     You mean i need to edit zf.bat file
>     SET ZF_SCRIPT=%PHP_DIR%\zf.php
>     Here in place of %PHP_DIR% i need to add the path of my PHP directory?
>     Can you plzz help me out.
>     4) D:\Informatik\SERVER\xampp\htdocs>D:\Informatik\SERVER\xampp\php\ZendFramework\b
>     in\zf.bat create project testproject********
vikram raghuwanshi