Programmer's Reference Guide

Zend Framework & MVC Einführung

Das Projekt erstellen

Um das eigene Projekt zu erstellen muss man zuerst Zend Framework herunterladen und extrahieren.

Zend Framework installieren

Der einfachste Weg um Zend Framework zusammen mit einem kompletten PHP Stack zu erhalten ist durch die Installation von » Zend Server. Zend Server hat native Installationsroutinen für Mac OSX, Windows, Fedora Core und Ubuntu, sowie ein universelles Installationspaket das mit den meisten Linux Distributionen kompatibel ist.

Nachdem Zend Server installiert wurde, können die Framework Dateien bei Max OSX und Linux unter /usr/local/zend/share/ZendFramework, und bei Windows unter C:\Program Files\Zend\ZendServer\share\ZendFramework gefunden werden. Der include_path ist dann bereits konfiguriert um Zend Framework zu verwenden.

Alternativ kann man » die letzte Version vom Zend Framework downloaden und dessen Inhalt extrahieren; man sollte sich notieren wo man das tut.

Optional kann der Pfad zum Unterverzeichnis library/ des Archivs den eigenen include_path Einstellung in der php.ini hinzugefügt werden.

Das ist es! Zend Framework ist jetzt installiert und bereit zur Verwendung.

Das Projekt erstellen

Hinweis: zf Kommandozeilen Tool
In der eigenen Zend Framework Installation ist ein Unterverzeichnis bin/ welches die Skripte zf.sh und zf.bat, für Unix-basierende und Windows-basierende Benutzer enthält. Der absolute Pfad zu diesem Skript sollte notiert werden.
Wo immer man einer Referenz auf den Befehl zf sieht, sollte der absolute Pfad zum Skript substituiert werden. Auf Unix-basierenden Systemen, könnte man die Alias Funktionalität der Shell verwenden: alias zf.sh=path/to/ZendFramework/bin/zf.sh.
Wenn man Probleme hat das zf Kommandozeilen Tool zu konfigurieren sollte man in das Handbuch sehen.

Ein Terminal öffnen (in Windows, Start -> Run und anschließend cmd verwenden). Zum Verzeichnis in dem man das Projekt beginnen will navigieren. Anschließend den Pfad zum richtigen Skript verwenden und eines der folgenden ausführen:

  1. % zf create project quickstart

Die Ausführung dieses Kommandos erstellt die grundsätzliche Site Struktur, inklusive den initialen Controllern und Views. Der Baum sieht wie folgt aus:

  1. quickstart
  2. |-- application
  3. |   |-- Bootstrap.php
  4. |   |-- configs
  5. |   |   `-- application.ini
  6. |   |-- controllers
  7. |   |   |-- ErrorController.php
  8. |   |   `-- IndexController.php
  9. |   |-- models
  10. |   `-- views
  11. |       |-- helpers
  12. |       `-- scripts
  13. |           |-- error
  14. |           |   `-- error.phtml
  15. |           `-- index
  16. |               `-- index.phtml
  17. |-- library
  18. |-- public
  19. |   |-- .htaccess
  20. |   `-- index.php
  21. `-- tests
  22.     |-- application
  23.     |   `-- bootstrap.php
  24.     |-- library
  25.     |   `-- bootstrap.php
  26.     `-- phpunit.xml

Wenn man an diesem Punkt, Zend Framework dem eigenen include_path nicht hunzugefügt hat, empfehlen wir Ihn entweder in das eigene library/ Verzeichnis zu kopieren oder zu symlinken. In jedem Fall sollte man entweder das library/Zend/ Verzeichnis der Zend Framework Installation rekursiv in das library/ Verzeichnis des Projekts kopieren oder symlinken. Auf unix-artigen Systemen würde das wie folgt aussehen:

  1. # Symlink:
  2. % cd library; ln -s path/to/ZendFramework/library/Zend .
  3.  
  4. # Copy:
  5. % cd library; cp -r path/to/ZendFramework/library/Zend .

Auf Windows Systemen ist es am einfachsten das vom Explorer zu tun.

Jetzt da das Projekt erstellt wurde, sind die hauptsächlichen Artefakte die man verstehen sollte, die Bootstrap, die Konfiguration, die Action Controller und die Views.

Die Bootstrap

Die Bootstrap Klasse definiert welche Ressourcen und Komponenten zu initialisieren sind. Standardmäßig wird Zend Framework's Front Controller initialisiert und er verwendet application/controllers/ als Standardverzeichnis in dem nach Action Controllern nachgesehen wird (mehr davon später). Die Klasse sieht wie folgt aus:

  1. // application/Bootstrap.php
  2.  
  3. class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
  4. {
  5. }

Wie man sieht ist nicht viel notwendig um zu beginnen.

Konfiguration

Wärend Zend Framework selbst konfigurationslos ist, ist es oft notwendig die eigene Anwendung zu konfigurieren. Die Standardkonfiguration wird in application/configs/application.ini platziert und enthält einige grundsätzliche Direktiven für die Einstellung der PHP Umgebung (zum Beispiel ein- und ausschalten der Fehlermeldungen), zeigt den Pfad zur eigenen Bootstrap Klasse (wie auch dessen Klassenname), und den Pfad zu den eigenen Action Controllern. Das sieht wie folgt aus:

  1. ; application/configs/application.ini
  2.  
  3. [production]
  4. phpSettings.display_startup_errors = 0
  5. phpSettings.display_errors = 0
  6. includePaths.library = APPLICATION_PATH "/../library"
  7. bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
  8. bootstrap.class = "Bootstrap"
  9. appnamespace = "Application"
  10. resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
  11. resources.frontController.params.displayExceptions = 0
  12.  
  13. [staging : production]
  14.  
  15. [testing : production]
  16. phpSettings.display_startup_errors = 1
  17. phpSettings.display_errors = 1
  18.  
  19. [development : production]
  20. phpSettings.display_startup_errors = 1
  21. phpSettings.display_errors = 1

Verschiedene Dinge sollten über diese Datei gesagt werden. Erstens kann man, wenn INI-artige Konfigurationen verwendet werden, direkt auf Konstanten referenzieren und Sie erweitern; APPLICATION_PATH selbst ist eine Konstante. Zusätzlich ist zu beachten das es verschiedene definierte Sektionen gibt: production, staging, testing, und development. Die letzten drei verweisen auf Einstellungen der "production" Umgebung. Das ist ein nützlicher Weg die Konfiguration zu organisieren und stellt sicher das die richtigen Einstellungen in jeder Stufe der Anwendungsentwicklung vorhanden sind.

Action Controller

Die Action Controller der Anwendung enthalten den Workflow der Anwendung und mappen eigene Anfragen auf die richtigen Modelle und Views.

Ein Action Controller sollte ein oder mehrere Methoden haben die auf "Action" enden; diese Methoden können über das Web abgefragt werden. Standardmäßig folgen Zend Framework URL's dem Schema /controller/action wobei "controller" auf den Namen des Action Controllers verweist (ohne den "Controller" Suffix) und "action" auf eine Action Methode verweist (ohne den "Action" Suffix).

Typischerweise benötigt man immer einen IndexController, der ein Fallback Controller ist und auch als Homepage der Site arbeitet, und einen ErrorController der verwendet wird um Dinge wie HTTP 404 Fehler zu zeigen (wenn der Controller oder die Action nicht gefunden wird) und HTTP 500 Fehler (Anwendungsfehler).

Der standardmäßige IndexController ist wie folgt:

  1. // application/controllers/IndexController.php
  2.  
  3. class IndexController extends Zend_Controller_Action
  4. {
  5.  
  6.     public function init()
  7.     {
  8.         /* Den Action Controller hier initialisieren */
  9.     }
  10.  
  11.     public function indexAction()
  12.     {
  13.         // Action Body
  14.     }
  15. }

Und der standardmäßige ErrorController ist wie folgt:

  1. // application/controllers/ErrorController.php
  2.  
  3. class ErrorController extends Zend_Controller_Action
  4. {
  5.  
  6.     public function errorAction()
  7.     {
  8.         $errors = $this->_getParam('error_handler');
  9.  
  10.         switch ($errors->type) {
  11.             case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
  12.             case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
  13.             case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
  14.  
  15.                 // 404 Fehler -- Controller oder Action nicht gefunden
  16.                 $this->getResponse()->setHttpResponseCode(404);
  17.                 $this->view->message = 'Page not found';
  18.                 break;
  19.             default:
  20.                 // Anwendungsfehler
  21.                 $this->getResponse()->setHttpResponseCode(500);
  22.                 $this->view->message = 'Application error';
  23.                 break;
  24.         }
  25.  
  26.         $this->view->exception = $errors->exception;
  27.         $this->view->request   = $errors->request;
  28.     }
  29. }

Es ist zu sehen das (1) der IndexController keinen echten Code enthält, und (2) der ErrorController auf eine "view" Eigenschaft verweist. Das führt schon zu unserem nächsten Subjekt.

Views

Views werden im Zend Framework in reinem alten PHP geschrieben. View Skripte werden unter application/views/scripts/ platziert, wo Sie weiters kategorisiert werden indem der Name des Controllers verwendet wird. In unserem Fall haben wir einen IndexController und einen ErrorController, und deshalb haben wir entsprechende index/ und error/ Unterverzeichnisse in unserem View Skript Verzeichnis. In diesem Unterverzeichnissen finden und erstellen wir anschließend View Skripte die jeder ausgeführten Controller Action entsprechen; im Standardfall haben wir die View Skripte index/index.phtml und error/error.phtml.

View Skripte können jedes Markup enthalten das man haben will, und verwenden das öffnende <?php Tag und das schließende ?> Tag um PHP Direktiven einzufügen.

Das folgende wird standardmäßig für das index/index.phtml View Skript installiert:

  1. <!-- application/views/scripts/index/index.phtml -->
  2. <style>
  3.  
  4.     a:link,
  5.     a:visited
  6.     {
  7.         color: #0398CA;
  8.     }
  9.  
  10.     span#zf-name
  11.     {
  12.         color: #91BE3F;
  13.     }
  14.  
  15.     div#welcome
  16.     {
  17.         color: #FFFFFF;
  18.         background-image: url(http://framework.zend.com/images/bkg_header.jpg);
  19.         width:  600px;
  20.         height: 400px;
  21.         border: 2px solid #444444;
  22.         overflow: hidden;
  23.         text-align: center;
  24.     }
  25.  
  26.     div#more-information
  27.     {
  28.         background-image: url(http://framework.zend.com/images/bkg_body-bottom.gif);
  29.         height: 100%;
  30.     }
  31.  
  32. </style>
  33. <div id="welcome">
  34.     <h1>Willkommen zum <span id="zf-name">Zend Framework!</span><h1 />
  35.     <h3>Das ist die Hauptseite unseres Projekts<h3 />
  36.     <div id="more-information">
  37.         <p>
  38.             <img src="http://framework.zend.com/images/PoweredBy_ZF_4LightBG.png" />
  39.         </p>
  40.  
  41.         <p>
  42.             Hilfreiche Links: <br />
  43.             <a href="http://framework.zend.com/">Zend Framework Website</a> |
  44.             <a href="http://framework.zend.com/manual/en/">Zend Framework
  45.                 Handbuch</a>
  46.         </p>
  47.     </div>
  48. </div>

Das error/error.phtml View Skript ist etwas interessanter da es einige PHP Konditionen verwendet:

  1. <!-- application/views/scripts/error/error.phtml -->
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN";
  3.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <head>
  6.   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7.   <title>Zend Framework Standardanwendung</title>
  8. </head>
  9. <body>
  10.   <h1>Ein Fehler ist aufgetreten</h1>
  11.   <h2><?php echo $this->message ?></h2>
  12.  
  13.   <?php if ('development' == $this->env): ?>
  14.  
  15.   <h3>Information der Exception:</h3>
  16.   <p>
  17.       <b>Nachricht:</b> <?php echo $this->exception->getMessage() ?>
  18.   </p>
  19.  
  20.   <h3>Stack Trace:</h3>
  21.   <pre><?php echo $this->exception->getTraceAsString() ?>
  22.   </pre>
  23.  
  24.   <h3>Anfrage Parameter:</h3>
  25.   <pre><?php echo var_export($this->request->getParams(), 1) ?>
  26.   </pre>
  27.   <?php endif ?>
  28.  
  29. </body>
  30. </html>

Einen virtuellen Host erstellen

Für die Zwecke dieses Quickstarts nehmen wir an das der » Apache Web Server verwendet wird. Zend Framework arbeitet auch perfekt mit anderen Web Server -- inklusive Microsoft Internet Information Server, Lighttpd, Nginx und andere -- aber die meisten Entwickler sollten zumindest mit Apache umgehen können, und es bietet eine einfache Einführung in Zend Framework's Verzeichnisstruktur und die Möglichkeiten des Rewritings.

Um den eigenen VHost zu erstellen muss man den Ort der eigenen httpd.conf Datei kennen und potentiell auch wo andere Konfigurationsdateien platziert sind. Einige übliche Orte sind:

  • /etc/httpd/httpd.conf (Fedora, RHEL, und andere)

  • /etc/apache2/httpd.conf (Debian, Ubuntu, und andere)

  • /usr/local/zend/etc/httpd.conf (Zend Server auf *nix Maschinen)

  • C:\Program Files\Zend\Apache2\conf (Zend Server auf Windows Maschinen)

In der eigenen httpd.conf (oder httpd-vhosts.conf auf anderen Systemen) muss man zwei Dinge tun. Erstens sicherstellen das der NameVirtualHost definiert ist; typischerweise wird man Ihn auf einen Wert von "*:80" setzen. Zweitens einen virtuellen Host definieren:

  1. <VirtualHost *:80>
  2.     ServerName quickstart.local
  3.     DocumentRoot /path/to/quickstart/public
  4.  
  5.     SetEnv APPLICATION_ENV "development"
  6.  
  7.     <Directory /path/to/quickstart/public>
  8.         DirectoryIndex index.php
  9.         AllowOverride All
  10.         Order allow,deny
  11.         Allow from all
  12.     </Directory>
  13. </VirtualHost>

Es gilt verschiedene Dinge zu beachten. Erstens ist zu beachten dass die DocumentRoot Einstellung das Unterverzeichnis public des eigenen Projekts spezifiziert; dies bedeutet das nur Dateien in diesem Verzeichnis jemals direkt vom Server serviert werden. Zweitens sind die Direktiven AllowOverride, Order, und Allow zu beachten; diese erlauben uns htacess Dateien in unserem Projekt zu verwenden. Wärend der Entwicklung ist das eine gute Praxis, da es verhindert den Web Server konstant zurücksetzen zu müssen wenn man Änderungen in den Site Direktiven macht; trotzdem sollte man in der Produktion den Inhalt der htacess Datei in die Server Konfiguration verschieben und diese deaktivieren. Drittens ist die SetEnv Direktive zu beachten. Was wir hier erledigen ist das Setzen einer Umgebungsvariable für den eigenen virtuellen Host; diese Variable wird in der index.php geholt und verwendet um die Konstante APPLICATION_ENV für unsere Zend Framework Anwendung zu setzen. In der Produktion kann diese Direktive unterdrückt werden (in diesem Fall wird es auf den Standardwert "production" verweisen) oder Sie explizit auf "production" setzen.

Letztendlich muss man einen Eintrag in der eigenen hosts Datei hinzufügen welche mit dem Wert korrespondiert der in der ServerName Direktive plaziert wurde. Auf *nix-artigen Systemen ist das normalerweise /etc/hosts; auf Windows findet man typischerweise C:\WINDOWS\system32\drivers\etc in Ihm. Unabhängig vom System sieht der Eintrag wie folgt aus:

  1. 127.0.0.1 quickstart.local

Den Webserver starten (oder ihn Restarten), und man sollte bereit sein weiterzumachen.

Checkpoint

An diesem Punkt sollte man in der Lage sein die initiale Zend Framework Anwendung auszuführen. Der Browser sollte auf den Servernamen zeigen welcher im vorherigen Abschnitt konfiguriert wurde; ab diesem Zeitpunkt sollte man in der Lage sein die Startseite zu sehen.


Zend Framework & MVC Einführung

Comments

mod_rewrite rules are defined in the .htaccess in the downloadable quickstart package. They are not covered by this quickstart guide and also lead to a apache error in case the Rewrite module is not enabled.
In case anyone is running through this tutorial in Windows, where the text above refers to symlinking, the equivalent steps for Windows 7 are as follows:
- change directory to your quickstart project folder ("cd <foldername>")
- delete the empty library folder that the zf installer created ("rm library")
- link the library folder from your ZF installation point ("mklink /D library '<ZF install path>/share/ZendFramework/library'")

If you're using earlier versions of Windows you could use the junction command, but it's a bit risky, so maybe better off copying the library folder contents?

When the values of form are empty. The message appears that my message is sent and if i don`t see it it can be under moderating bla bla bla. But from wasnt sent cause of the required fields are empty.
It a BUG :-)))
When the values of form are empty. The message appears that my message is sent and if i don`t see it it can be under moderating bla bla bla. But from wasnt sent cause of the required fields are empty.
It a BUG :-)))
When the values of form are empty. The message appears that my message is sent and if i don`t see it it can be under moderating bla bla bla. But from wasnt sent cause of the required fields are empty.
It a BUG :-)))
When the values of form are empty. The message appears that my message is sent and if i don`t see it it can be under moderating bla bla bla. But from wasnt sent cause of the required fields are empty.
It a BUG :-)))
When the values of form are empty. The message appears that my message is sent and if i don`t see it it can be under moderating bla bla bla. But from wasnt sent cause of the required fields are empty.
It a BUG :-)))
Hi. I running Zend Framework 1.10.1 on Ubuntu server 9.10.
zf show version return me that I have the latest version of zend framework

root@web-server:/var/www# zf show version
Zend Framework Version: 1.10.1

When I run which zf it returns me
root@web-server:/var/www# which zf
/usr/bin/zf

On zf show config:
User Configuration: /root/.zf.ini
`-- php
`-- includepath: .:/usr/share/php:/usr/share/pear

The problem appear when i'm trying to setup a new zend framework project bu running "zf create project <name_project>", it returns me the following:

root@web-server:/var/www# zf create project test
An Error Has Occurred
Provider 'project' is not a valid provider.
I have run this commant as simple user, and as root, same problem appear each time. It works on previous versin of Zend framework. It has been removed, it's a bug or I did something wrong?
may it will be usefull for newbies (as i've spent a lot of time figuring that one out).
to start using apache vhosts config the following line should be uncommented in httpd.conf:
Include conf/extra/httpd-vhosts.conf
and <VirtualHost> info added to conf/extra/httpd-vhosts.conf file
When I run the zf.bat for example, gives me an error in the log. Check the settings and paths, all right. What else should I need check?
I'm try this tutorial and get this error

An error occurred
Page not found
Exception information:
Message: Invalid controller specified (quickstart)

Stack trace:
#0 D:\wamp\www\quickstart\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#1 D:\wamp\www\quickstart\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch()
#2 D:\wamp\www\quickstart\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#3 D:\wamp\www\quickstart\public\index.php(26): Zend_Application->run()
#4 {main} Request Parameters:
array (
'controller' => 'quickstart',
'action' => 'index',
'module' => 'default',
)


any suggestion for this error?
Solved "Provider 'project' is not a valid provider" under Windows.

Turned out there was a (default?) zf.bat in my xamp/php folder and xamp/php was in my path before my zend/bin folder.

If you don't need the space, unpack the whole framework under a folder and add that folder/bin to you path. You do not have to reboot but you do need to restart (close and reopen) your command prompt.

Good luck!
Solved "Provider 'project' is not a valid provider" under Windows.

Turned out there was a (default?) zf.bat in my xamp/php folder and xamp/php was in my path before my zend/bin folder.

If you don't need the space, unpack the whole framework under a folder and add that folder/bin to you path. You do not have to reboot but you do need to restart (close and reopen) your command prompt.

Good luck!
Virtual host entry for Zend Server CE requires an additional "Listen 80" statement for this vhost to work. Zend Server CE listens on 10088 only by default.
In addition to Alexander's comment, in Debian this is a quick way to enable Rewrite mode for Apache2 (if you get 500 error check your php and apache logs):

cd /etc/apache2/mods-enabled/
sudo ln -s /etc/apache2/mods-available/rewrite.load ./rewrite.load
sudo /etc/init.d/apache2 reload

How can I have Zend_Tool create an XML config file instead of a dreaded INI? This should be trivial, but since documentation on zf is lacking could someone shed some light on this? Creating a custom profile with <applicationConfigFile type="xml"/> doesn't change a thing (which is pretty damn stupid), even though the .zfproject.xml file keeps this changed setting. So how should I go about it?
in the Views section, the script of index/index.phtml, line 34, 35

<h1>Welcome to the <span id="zf-name">Zend Framework!</span><h1 />
<h3>This is your project's main page<h3 />

'<h1 />' and '<h3 />' should be '</h1>' and '</h3>'?
OK but how do you configure the virtual host for windows IIS?

Thanks,

afh
After installing zend server, If you get this error when running zf create project
"This application failed to start because sqlite3.dll was not found. Re-installing the application may fix this problem." Go to this url, http://www.lizjamieson.co.uk/2008/06/03/sqlite3dll-was-not-found/
Its an artical on how to fix the problem.

-Alain
i am using backtrack 4 which is using apache2 server and my server root is /var/www/ . i have installed the zendframework according to guide of quickstart of zendframework on this site.

1. i inserted the path of /var/ZendFramework/library/ in to include_path of php.ini which is located at /etc/php5/apache2/php.ini at my system.

2. i also created the symink of /library directory of ZendFrameWork in the /var/www/quickstart/library/ .

3. i also insterted the line 127.0.0.1 quickstart.local in /etc/hosts file. where in /etc/hosts file two line are already inserted. after insterting the above line my file became :

127.0.0.1 localhost
127.0.1.1 backtrack bt
127.0.0.1 quickstart.local

4. In my system /etc/apache2/httpd.conf file is empty. so i inserted the virtual host code in this file as shown in quickstart guide of ZendFrameWork. ( I am surprised why httpd.conf file is empty).

5. i also insterd the virtual host code in /etc/apache2/apache2.conf at the end of file. but it still not working....... help me
















How to install zend fw on hosting without access to console?
I am very happy for this type tutorial,Where a fresh developer have get big help from this site....:)
Thanks for the Windows 7 tips for Apache and other useful information.
Code ignitor is better.

Zend is very hard to use and it take a lot of time to load websites.
Beacuse it has a lot of libraries.
Refer Codeignitor

But Zend Studio is Good. It has a excellent look and it will tell you everything while you coding.
Hi,

One error in this post comment. if we submit the form with out entering then success message appearing along with validation messages
403 Error- This is because there is not option for setting the root during Zend CE install. I wanted all my files to be on a different drive so i set up a vhost to that drive. Didnt know what was causing the error so i
ADD: ErrorLog "logs/com.quickstart.local.log"
<VirtualHost *:80>
ErrorLog "logs/com.quickstart.local.log"
</VirtualHost>
in log file found
Options FollowSymLinks or SymLinksIfOwnerMatch is off

Then i Added
<Directory "xxx\php\quickstart\public">
Options Indexes FollowSymLinks
</Directory>



There is a need to set the virtual host only for this project and not for all hosting.
So, looks at this:
NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
#ServerAlias domain.tld *.domain.tld
DocumentRoot C:/xampp/htdocs
</VirtualHost>

<VirtualHost *:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>

Instead of the last setting above code, use the virtualHost discussed.
For localhost to work use the top two para.


// satya

Comment on aliasing:

in my local OSX snow leopard:

the alias instructions above show:
alias zf.sh=/usr/local/zend/share/ZendFramework/bin/zf.sh

if that alias is created, the commands must be run as:
zf.sh show version

instead I created the alias as:
alias zf=/usr/local/zend/share/ZendFramework/bin/zf.sh

this allows me to run:
zf show version

small tip:
1 open a terminal window
2 type: alias zf=
3 drag and drop the file /usr/local/zend/share/ZendFramework/bin/zf.sh onto the terminal window and the file path is filled-in



Problem:
zf.sh and zf.php would hang when executed.

Reason:
I already had an older version of Zend configured in my php.ini include_path (for work). After it was removed everything worked like a charm.
Those who are facing difficulty configuring the Zend Framework can refer to me blog at:

<a href="http://www.faisalkaleem.com/php/a-comprehensive-guide-how-to-install-zend-famework.html">www.faisalkaleem.com/php/a-comprehensive-guide-how-to-install-zend-famework.html</a>

I hope you will find much easier guide here.
Any body can help me for complete sample code of zend soap server client with mysql. i am just novitiate of zend . how can we create wsdl file , soap server and soap client via zend. does zend provide any better way.

i waana just MVC archt for showing mysql data through of zend soap server and client and wsdl.

Guys Help Me,
If you can
Cheers!!
Hello!
After I had put zf create project ..., I didn't have a folder named public...
Thanks in advance!
The correct way to make an alias to zf on Linux is:
alias zf=path/to/ZendFramework/bin/zf.sh

The article incorrectly says to use:
alias zf.sh=path/to/ZendFramework/bin/zf.sh
hi i am new to zend frame work ..!

i installed the zend frame work on windows system and i stucked at include_path so please let me know to proceed from here ....

Waiting For your Support
The path to the Zend Framework as installed from the Ubuntu 10.10 repository is"

/usr/share/php/libzend-framework-php/Zend
READ THIS FIRST

After I finished this project, this tutorial makes sense. However, I had a hard time to understand the instructions and spent lots of time to read comments and try different things. The following is a tutorial for this tutorial.

Let me explain what I have done:
I installed Zend Server on my Window XP laptop PC. The Zend installer puts Zend Server software to C:\Program Files\Zend directory and created Apache2 and ZendServer directories.

To set up include_path mentioned in this tutorial:
Check PATH Environmental variable has the followings:
"C:\Program Files\Zend\ZendServer\bin";"C:\Program Files\Zend\ZendServer\share\ZendFramework\bin"
Note: To check the PATH, click on 'Start' on Window, right-click on 'My Computer', click on 'Properties', select 'Advanced', click on 'Environmental Variables'. Double-click on PATH in the second window.

To create a project: On DOS terminal,
Go to C:\Program Files\Zend\Apache2\htdocs then type this:
zf create project quickstart
Note: First time I created quickstart project at C:\some_dir, it didn't work. Please someone explain this!

IMPORTANT: copy and paste the subdirectory Zend in C:\Program Files\Zend\ZendServer\share\ZendFramework\library to C:\Program Files\Zend\Apache2\htdocs\quickstart\library, your project library directory.

Note: When you copy the content from files listed in this tutorial, for php files, add <?php on the first line of the file.

Note: All zf commands in this tutorial should be executed at C:\Program Files\Zend\Apache2\htdocs\quickstart\

Note: dada/db should be created at C:\Program Files\Zend\Apache2\htdocs\quickstart

MY PROBLEM:
http://quickstart.local/ works fine. It displays "Welcome to the Zend Framework!..." page.
http://quickstart.local/guestbook and http://quickstart.local/guestbook/sign work!!!
BUT http://localhost/ says 403 Forbidden: You don't have permission to access / on this server. As you know, I checked hosts, httpd.conf, httpd-vhosts.conf. Please help me!

Question: I already have C:\xampp\php\PEAR\Zend and C:\xampp\apache. Are these used at all? It seems it is NOT used at all because of Environmental Variables setup.

My two cents
Create your first zend application in 3 easy steps

http://hello-zend.blogspot.com/2011/01/first-application-in-3-steps-first-zend.html
The HTML markup is a little odd, i.e. the H3 close tag differs from usual practice. The syntax highlighting also looks like an editor that's not doing so well.

Jonathan, http://JonathansCorner.com/
I was stuck by the "error 500"
instructions in the comment by nadie solved the problem on ubuntu 10.10
Do this, do that, but remember this, unless this is that, or that is this, and then do this and this and this but only in some cases, now remember to do this, but it depends really.

Too complicated...Convoluted instructions...Etc.

I could more likely hand code something in less time than it would take to get all this working.
While Zend Framework is itself configurationless, you often need to configure your application.

this statement couldn't be more inaccurate. configure php.ini. configure virtual host. etc.

the Zend Framework documentation is all over the place. i have been playing with this for several hours and i'm still not sure if i'll be able to run a ZF app on a web server that's hosting many many other apps

still ZF is too promising for me to just ignore. i've used other MVC frameworks and that's definitely the way to go ( MVC )
follow up to my last post: i believe this tutorial is not compatible with the current release of ZF ( which is 1.11.5 as of 5/6/11 ). i recommend searching for ZF how to tutorials using your version #

and just so everyone knows ... once you have the zend library included in your php include_path variable ... you can view the ZF served pages by pointing your browser into the public/ directory. not the project root directory

good luck. i hope this follow up helps

b
If anyone else has problems by his provider using his own vHost configuration - maybe he'd prefer to write this simple htaccess-file into his root-directory:


RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^(/public/|/public)(.*)$
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ public/index.php [R=301]
OK, i did all the staff described above and it works just fine. But are you really serious about not even delivering an example with fully valid html-code. There are not even html tags in the output. I know browsers dont care anymore, but it really makes a bad first impression to me.
The coding you provided us is this is safe and in working situation. I agreed with you on the issue installing zend server, but I also see that this coding is uncomplete and may be a part of a program please provide full coding.
Watch This
http://www.home-loans.org.za/
This is Great
home loans
that looks a lot like spam for the sake of improving a site's SEO (see previous post)
I have big troubles by configuring the virtual host on my local machine (Operating System Windows 7 64 Bits) .

Since I have installed Zend Server Community Edition 5.0.3, all I need to do is to add the virtual host configuration as described above into the file with the following path:

C:\Program Files (x86) \Zend\Apache2\conf\httpd-vhosts.conf

I have also added the DNS name quickstart.local into the host into the file with following path:

C:\WINDOWS\system32\drivers\etc

So far everything working wel l...

After starting Apache2.2-Zend, the virtual host "quickstart.local" is activated but it is pointing on the "Zend Server Test Page" when I try to access the URL "http://quickstart.local" although the Document Root is set to: C:/mypath/to/quickstart/public

Has anybody an idea how I can fix this issue?
For those who had the same problem with "PHP5.dll not on computer..."

My problem, solution and explanation:

The following php.ini - Line occured an "PHP5.dll not found on computer..." Error by every php.exe call; eg: 'php -v' / 'zf.bat show version' / etc.

zend_extension_ts="C:\Apache22\modules\xdbug.dll"

If i added the "e", also "xdebug.dll" vs. "xdbug.dll" it will work fine without the "PHP5.dll not found on computer..." Error

BUT: the file "xdebug.dll" would not be found and in the case before ("xdbug.dll"), the file "xdbug.dll" would also not be found but shows in addition the Error "PHP5.dll not found on computer...". It could be a PHP BUG ?! I don't know. But if I get deeper I have noticed, that the Problem comes from the existing "modules/xdbug.dll" file. If I rename the file to "xdebug.dll" and change the PHP.ini Line to "xdebug.dll" I get again the "PHP5.dll not found..." error. It could be, that this Version of xdebug is'nt compatible with my PHP Version ?!

To finaly fix it, to have no "PHP5.dll missing..." Error and no Error for the "xdebug.dll" / "xdbug.dll" "not found", I comented it:

;zend_extension_ts="C:\Apache22\modules\xdebug.dll"

Good Luck

I am keen to get best updates about important things.Please do send me email about these updates.



http://www.auraprint.co.uk
After I finished this project myself, this tutorial makes sense. However, I was hard exercise for me understand the instructions and spent lots of time to read comments and try different things. <a href="http://www.hospitalplans.org.za">hospital plan</a>
I am going to use Zend Framework because features include components taht are fully object-oriented PHP for my breast augmentation Tampa website
This is awfully confusing. I would need hours of tuition to catch up on this. It might be useful for my Toenail Fungus Removal site if I could figure it ou. Well back to the drawing board, I guess
This is a very good article about getting Zend Framework. I have been looking for information like this to help my natural breast enhancement website. Thankyou
another one.. i m looking...for.. this for a long time..

<a href=http://networkmarketinginindia.com/> Network Marketing In India </a>
This tutorial guided me through the installation. Thanks for posting.

Joe at http://mlmadvertisingx.com

Zend frame work defines

1. High level goals for each component
2. Design intent of the component
3. Benefit gained from using this component
4. A link to the Programmer's Reference Guide for that component

That's what every web developer needs.
"Restart PHP" button in Zend server web interface doesn't work for me. (win7/chrome) If you have problems setting virtualhost, try to restart apache server manualy.
an error occurred Provider project is not a valid provider
Resolved

xampp already has a previous version of zend frame work.

make sure to over right zf.bat and zf.php along with zend library.

Little tip for W7 users:
when creating a project and you need to use the absolute path to zend use quotes for the path. Ex:

zf create project "C:\Program Files\Zend etc. etc."
instead of
zf create project C:\ Program Files


The latter will cause a project called "Program" to be created and an error on the "Files" command.

Also, open cmd.exe as an admin (right click, open as administrator) to create new projects in the htdocs folder in apache (it's in the program files folder, accessible only through admin rights, otherwise you'll get a mkdir() error).

hope this helps! :)
If You get 403 error with virtual host, make sure every single directory in your DocumentRoot is listable (chmod +x to fix).

Also to activate VirtualHost, just uncomment following line in httpd.conf:
Include conf/extra/httpd-vhosts.conf
Then update dummy vhosts in extra/httpd-vhosts.conf
ERRO 505

Certifique-se que o modo de re-escrita está ativo no apache.
Ensure that the re-writing mode is active in apache.

Debian/Ubuntu ----
$ a2enmod rewrite
----------------------
@Zolana Nsakala:

Not sure if this'll entirely fix your problem, but your hosts file shouldn't reference a file path directly - it should just refer to the local machine's ip.
So, instead of :
quickstart.local c:\blah\file\index.php
make it:
quickstart.local 127.0.0.1

This way, when apache receives a request, it looks in the document root path for an index file to serve.
hi i'm using xampp & windows 7 on my laptop and I change the default port llisten to 8080
how to configure the apache virtual host and the etc servername
thanks

I try this but not work
apache virtual host
<VirtualHost *:8080>
ServerName quickstart.local
DocumentRoot /ZendLearn/quickstart/public

SetEnv APPLICATION_ENV "development"

<Directory /ZendLearn/quickstart/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

windows etc
127.0.0.1:8080 quickstart.local
I tried to install zend to my xp edition, but I am really having a hard time. I've checked youtube as well so it would be easier for me to watch the steps, but it still wont work.

Help pls. <a href="http://internationalteachingjobs.org">international teaching jobs</a>
On windows using zend server, the 'restart php' button on the zend server control panel does not seem to restart apache as well.

In order to restart Apache (and get the virtual host setup described in the tutorial working) you should issue the following commands in a terminal


net stop Apache2.2-Zend && net start Apache2.2-Zend

(thanks to http://galide.jazar.co.uk/2011/02/zend-server-hosted-on-windows-restart.html) for getting me out of that one
I have a problem in Zend_Auth that works on windows and don't work on ubuntu .I use Xampp on windows and UNIX.What's the problem ?
Thanks for this tutorials

when implementing the "zf create project quickstart", there is a warning that i do not have the phpunit. "this is nothing" i thought.

after 3 days could not get the checkpoint of "welcome page" (500 Internal Server Error), i finally solved this problem by "apt-get install phpunit" and modified
include_path = ".:/etc/php5/zendFramework_1.11.10/library:/usr/share/php:/usr/share/php/PHPUnit"

hope this will be helpful
Thanks for the great post on your blog, it really gives me an insight on this topic. Keep it up.
<a href="http://getoldboyfriendback">Get old boyfriend back</a>
Hi,i'm just a newbie
i don't understand i got this error "HTTP Error 404. The requested resource is not found." while i've properly configured the httd-conf file and the host file(Windows 7) i need help please i've been stuck for 24 hours
When I run the command "zf create project quickstart", there is an error "Failed loading ZendDebugger.dll". How to fix this problem?
Hei Folks,
use ubuntu and eclipse to enjoy the development, it works like sharm, windows s...ks!!
After installing and getting the virtual hosts to work, I kept getting this error:

ERROR! Manager of pid-file quit without updating file.

for MySQL and I could not login to phpMyAdmin. phpMyAdmin gave the following error:

#2002 Cannot log in to the MySQL server

I went through several things to try to solve this including changing the permissions on /tmp, /private/tmp/, and /usr/local/zend/mysql*. Also, I shutdown two mysqld services via:
ps -ax and kill -9 ####
where ##### is the pid.

None of that worked but this did:
http://www.worldgoneweb.com/2010/zend-server-community-edition-for-mac-os-x-mysql-problem/

which basically says to call /usr/local/zend/mysql/scripts/mysql_install_db


For Ubuntu 10.10 with apache2 use the follow settings :-

(Assuming the path to your Zend application's public directory is /var/www/quickstart/public

In /etc/apache2/sites-available/default add :-

<VirtualHost *:80>
ServerName quickstart.local
DocumentRoot /var/www/quickstart/public

SetEnv APPLICATION_ENV "development"

<Directory /var/www/quickstart/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

In /etc/hosts add :-

127.0.0.1 quickstart.local


restart/reload apache2 : sudo /etc/init.d/apache2 restart

Works like a charm!







I have to rebuilt my website about GPS to Zend. I see it's a good framework.

Following this tutorial exactly on Mac OS X 10.7 with MAMP PRO

I've double checked everything but I'm still getting this error:

Page not found
Exception information:

Message: Invalid controller specified (quickstart.local)

Stack Trace:
#0 /Applications/MAMP/bin/php/php5.3.6/lib/php/ZF1.11.11/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#1 /Applications/MAMP/bin/php/php5.3.6/lib/php/ZF1.11.11/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#2 /Applications/MAMP/bin/php/php5.3.6/lib/php/ZF1.11.11/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#3 /Applications/MAMP/htdocs/quickstart/public/index.php(26): Zend_Application->run()
#4 {main}

Request Parameters:

array (
'controller' => 'quickstart.local',
'action' => 'Index',
'module' => 'default',
)


If it makes any difference, I'm not a new developer, so please spare me the "check your typing" line, that's done.
@Steven:

I still assume you have a typo somewhere in your application.ini or another file (maybe the controllers themselves).

Check wether the line
resources.frontController.controllerDirectory = APPLICATION_PATH "/controller[b]s[/b]"

is typed correctly and the directory actually exists and contains controllers (the one you actually load from your browser, e.g. /test -> TestController.php).

Same goes for the const APPLICATION_PATH - check if it does point to the correct directory.

I had set the controllerDirectory to "controller" (note the trimmed "s") and got the same error message and stack trace, which lead to this conclusion.

Anyway, if you have found the mistake, I'd be pleased to hear your solution by sending me an email schindhelm ( at ) gmail ( dot ) com.

Kind regards from Germany,

René
David, for your localhost (wamp page) forbidden http message
you need to add this block in your apache virtual hosts configuration file :

<VirtualHost *:80>
ServerName localhost
DocumentRoot "c:\wamp\www"
<Directory c:\wamp\www>
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
HTML-Tags:
Open <$tagename>
Close </$tagname>

See your's:
<h3>This is your project's main page<h3 />

failed

+ Add A Comment

Please do not report issues via comments; use the ZF Issue Tracker.

If you have a JIRA/Crowd account, we suggest you login first before commenting.

  • BBCode is allowed in the comment markup

  • Select a Version

    Languages Available

    Components

    Search the Manual