Programmer's Reference Guide
| Schnellstart in den Zend Framework |
Zend Framework & MVC Einführung
Zend Framework
Zend Framework ist ein Open Source, objektorientierter Web Anwendungs Framework für PHP 5. Zend Framework wird oft eine "Komponentenbibliothek" genannt, weil er viele lose verbundene Komponenten hat die man mehr oder weniger unabhängig verwenden kann. Aber Zend Framework bietet auch eine fortgeschrittene Model-View-Controller (MVC) Implementation die verwendet werden kann um eine Basisstruktur für eigene Zend Framework Anwendungen zu sein. Eine komplette Liste der Komponenten des Zend Frameworks mit einer kurzen Beschreibung kann in der » Komponenten Übersicht gefunden werden. Dieser Schnellstart zeigt einige der am meisten verwendeten Komponenten vom Zend Framework, inklusive Zend_Controller, Zend_Layout, Zend_Config, Zend_Db, Zend_Db_Table, Zend_Registry, zusammen mit ein paar View Helfern.
Durch Verwendung dieser Komponenten bauen wir eine einfache Datenbank-gesteuerte Guest Book Anwendung in wenigen Minuten. Der komplette Quellcode für diese Anwendung ist in den folgenden Archiven vorhanden:
Model-View-Controller
Was also ist dieses MVC Pattern über das alle Welt redet, und warum sollte es verwendet werden? MVC ist viel mehr als nur ein drei-wortiges Acronym (TLA) das man erwähnen kann wann immer man smart erscheinen will; es ist so etwas wie ein Standard bei der Erstellung von modernen Web Anwendungen. Und das aus gutem Grund. Der Code der meisten Web Anwendungen fällt in einer der folgenden drei Kategorien: Präsentation, Business Logik, und Datenzugriff. Das MVC Pattern modelliert diese Trennung bereits sehr gut. Das Endergebnis ist, das der Präsentationscode in einem Teil der Anwendung konsolidiert werden kann, die Business Logik in einem anderen Teil und der Code für den Datenzugriff wieder in einem anderen. Viele Entwickler finden diese gut definierte Trennung unentbehrlich um deren Code organisiert zu halten, speziell wenn mehr als ein Entwickler an der gleichen Anwendung arbeitet.
Hinweis: Mehr Informationen
Brechen wir das Pattern auf und schauen wir uns die individuellen Teile an:
Natürlich gibt es über dieses kritische Pattern » mehr zu sagen, aber das gesagte sollte genug Hintergrund vermitteln um die Guestbook Anwendung zu verstehen die wir bauen wollen.
Modell - Dieser Teil der eigenen Anwendung definiert die grundsätzliche Funktionalität in einem Set von Abstraktionen. Datenzugriffs Routinen und etwas Business Logik kann im Model definiert sein.
View - Views definieren was exakt dem Benutzer präsentiert wird. Normalerweise übergeben Controller Daten in jede View damit Sie in einem Format dargestellt werden. Views sammeln auch oft Daten vom Benutzer. Dort findet man üblicherweise HTML Markup in der eigenen MVC Anwendung.
Controller - Controller verbinden das komplette Pattern. Sie manipulieren Modelle, entscheiden welche View, basieren auf der Benutzeranfrage und anderen Faktoren, angezeigt werden soll übergeben die Daten welche jede View benötigt, oder übergeben die Kontrolle komplett an andere Controller. Die meisten MVC Experten empfehlen » Controller so schlank wie möglich zu halten.
| Schnellstart in den Zend Framework |


Comments
While the zend framework quickstart is the best place to introduce yourself to zend framework, you may have discovered that it doesn't actually work out-of-the-box (especially for windows users). after going through the pain of completing the tutorial, I thought it would be kind of me to go back with a fresh windows system and address all the errors that occur with an out-of-the-box setup. So i reset any changes made to windows, uninstalled all my wamp and zend files and started again.
Below you can see how i addressed all the issues that occurred while following the quickstart tutorial. Hope it helps!
You will probably want a code editor to view some of the necessary files, rather than notepad. I use PSPad editor. it's free and works well.
Also note that if you choose a different directory structure than mine, you will have to update the paths used here according to your setup.
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...
<VirtualHost *:80>
DocumentRoot "c:\zendSites\quickstart\public"
ServerName quickstart.local
SetEnv APPLICATION_ENV "development"
<Directory c:\zendSites\quickstart\public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:\wamp\www
ServerName localhost
</VirtualHost>
...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 (<?php ?>). 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!
Am I completely missing the point here? (BTW, galaera: The fact you posted all of this is quite amazing. Without it, I would have been groping around for hours trying to understand why the system was not working. Can someone from zend explain themselves here? Or, show us where we are wrong and poinit us in the right direction????
What's up with this installation? It seems like you've put a tremendous amount of work into an elaborate IDE and then short circuited on the example setup.
Thanks for the error resolution. Would you be able to provide the same instructions but instead of using Apache, use IIS?
Thanks for considering.
afh
in windows
I have to type http://localhost/zfpurifyne/public/ in address bar to get the main page to display. Why can't i just type http://localhost/zfpurifyne
sorry for the repeats, bb code and captcha are holding me up
If there is a way to setup a server and an editor to build websites, please let me know. As of right now, I can't figure out which Zend I am trying to use, am I using Zend framework, Zend Studio, Zend server? Seriously, it is reallly confusing. I saw hope when I saw the framework stack, but I still can't get the web pages I am building to show on localhost.
Beltnato- still wonderful work on the above explanation.
Put Customer service back as a priority rather then the almighty $$$. Fix your internal problems then developers might start-using your tools again!
I think that there should be a prefix outlining "assumed knowledge" to this manual and something that separates stipulates that Zend Framework is not Zend Studio and that they are separate.
This would save some newcomers the confusion and light the way for beginners who want to pick ZF up so they are not overwhelmed and not scare away Zend Studio sales.
Just a thought.
In response to a comment that stuck out to me regarding this being a money grab for training and Zend Studio.
It most certainly is not. I regard the Zend Framework as a separate entitiy. The Zend Framework project is an open source framework built by a community supported and guided by Zend and they are collectively doing an amazing job.
Here's a list of the contributors:
http://framework.zend.com/community/contributors
Zend Studio has features that integrate the framework with the IDE, but this does not mean that you have to use ZF to be able to use Zend Studio. It's just a feature of the IDE.
If you want to learn more "What is Zend Framework?" in the wiki.
http://framework.zend.com/wiki/pages/viewpage.action?pageId=10530
regards,
rvdavid
http://www.rvdavid.net/
I am currently working in codeIgnitter framework.this is also having MVC architecture,And i would like to increase my knowledge by learning zend framework so anybody can help me how i learn this framework easily.And please provide me notes for this.
Thanks
Sanjay
I have an account on an web host where I can access via ftp to apache /htdocs directory and I can configure .htaccess on root.
I downloaded Zend Framework 1.10.8 and upload via ftp on my host in /htdocs/
I created via Zend 8 Zend Framework Example Project named ZFEP and uploaded in /htdocs/ZFEP
I added in /htdocs/.htaccess follow line to include zend framework:
php_value include_path ".:/home/vol3/byethost12.com/MYUSERNAME/htdocs/zend/library"
When I acces to http://www.mydomain.com/ZFEP/public/index.php show main page of Zend.
In upper right corner there is the application guestbook when I click I see in browser bar direction http://www.mydomain.com/ZFEP/public/index.php/guestbook
and go out follow page
ZF Quickstart Application Guestbook
An error occurred
Application error
I spent four day to solve this error without results.
Now I hope somebody can help me.
My hipotesis is that zend framework is installed in /htdocs/zend this is zend server for my idea.
I've setted include zend with apache directive php_value include_path so zend automatically is setted.
Why go out this error? Somebody can help me to run Zend Framework Example Project on my web space to start to know this framework?
Thank you for every help
ZEND FRAMEWORK DOES NOT WORK ON REMOTE SERVERS BECAUSE MOST WEB SERVER PROVIDERS HAVE A STANDARD CONFIGURATION AND YOU CANNOT MODIFY IT!
SOTHEREFORE I BEG THE ALL THOSE DEVELOPING ZEND FRAMEWORK TO START THINKING ON HOW ZEND FRAMEWORK COULD WORK WITH THE MOST COMMON WEB SERVERS PROVIDERS CONFIGURATION!
THANKS. PHP 4 AND 5 VETERAN!
Thanks for considering.http://google.com or <a href="http://google.com">G</a>
another example of open source profiteering
notepad rules OK
<html><body>Hello World!</body></html>
that should really be clear.
But, on the other hand, i too invested about four hours now to find out whether Zend would save me time (for a big web2.0 app project) or eat my days learning another damn framework.
Anyway, the ubercommercial appeal helped me making a negative decision - maybe forever!
http://hello-zend.blogspot.com/2011/01/first-application-in-3-steps-first-zend.html
Some of the features I have used in Zend Framework is AJAX (try it yourself, every click only loads the main content and does not reload page). In communities this is important to reduce server load and bandwidth.
Other great features that ZF is really good at is the Zend_View and Zend_Layout template and output engine. I've used it on the above sites to create alternative contents such as Facebook App, AJAX/NON AJAX and mobile. the best thing is that it is really MVC, I can create new views using same controllers in no-time, it is really helpful.
Before I started building our social platform I did research and tried different frameworks such as Symfony but ZF was a clear winner for me. See my blog post about that (in Swedish, use Google Translate): http://hogberg.net/2008/10/utvrdering-av-utvecklingsverktyg-fr.html
So, the MVC implementation in ZF is really good, no doubt about it.
###### crazy while working on Zend.
If you buy a computer game and you want to play the game whatever will happen, but your hardware doesn't support it, would you buy and install new hardware or bring the game back to the shop?
If someone will show me a framework which will learn my brain php/apache/http overnight...pssst... please tell me... we will get rich over night, too!!!
Joke.
Learn php/html/http/css etc.
Learn something about your favourite server. (And please settup your own... not a special configured one from your provider... it takes a lot of fun to change the settings specially for you)
Learn something about the framework. (Oh, yes... you have to install it)
Try to develop the same php-project done before -> now in zend.
Try to ask a clear question -> You'll get a good answer!
We will meet in 5-6 years again:) (Normaly Brain, no freak)
And yes..... I've to learn some English next time :)
I build my website Newly Domains by ZendFramework.
Surely not a user-friendly framework, has great features though.
Surely not a user-friendly framework, has great features though.
Surely not a user-friendly framework, has great features though.
But the documents is not good,
I can not find something quickly.
can you improve this?
This is my server config
- Apache 2.2.11
- MySQL 5.1.36
- PHP 5.3.0
Zend Framework 1.10.3
Does anyone have a detailled guide on how to install Zend framework from A to Z?
thanks
i set my ZF site on a LAMP stack. this won't apply to people trying to get ZF working on Windows servers.
configure the .htaccess file for your project root directory ...
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
php_value include_path ".:zend/library/Zend/"
you will have to set your include path for your machine. i noticed there was some variation in the include path once you got inside the ZF structure. older ZF versions had the all import includes in the /zendframework/library/ path. as of 1.11.5 ... the path is now /zendframework/library/Zend/.
i used the ZF (zf.sh) to set up file structure for my project. within /root/library/ i create a symbolic link to the mighty /zendframework/library/Zend/ path ... like this:
cd ... to the /root/library/ path
and create a symbolic link like this ...
ln -s /absolute/path/to/zend/framework/library/Zend/
from within /root/library/ ... type 'ls' ... you should see an oddly colored /Zend ... folder ... since this is not an actual directory but a symbolic link (alias) to the /zendframework/library/Zend/ directory
i didn't have to mess with php.ini files using this method. i think that's everything. or at least the major sticking points
regards,
b
Im sam, how is everyone?
I look forwards to being a active memeber
But it's not suited to personal development.Because ZF is so big!!!
Tampa seo business site. Can I use my own server or a server at godaddy or does it not matter? Thank you for any input
For example:
Zend_Application_Bootstrap_Bootstrap
???
Hey noobs, there are NAMESPACES in PHP !
i am new in Zend can you provide me some guide line for development .
replace override "none" by "All" in C:\Program Files\Zend\Apache2\conf\http.conf
it's running well
<a href="http://modelosdeelite.com.br/">Acompanhantes</a>
i do not know how to run my files on live site please send me the settings and steps
---------------thank you
regards <a href="http://watchtruebloodseason4.com">true blood episode</a>.
Natural laxative foods I am hoping to read more helpful articles from you.
We are so happy that the zend project was able to help us complete the plumber fort myers.
Thanks for the error resolution!
<a href="http://www.bizsuteka.hu>bizsuk</a>, <a href="http://www.uvegterasz.hu>terasz</a>
you guys could easily abstract your brain away, take care :D
thx for the post
I followed what there was for a tutorial, several times, and always get the same error -- which is never mentioned in any search I've done. You never mention(ed) anything about IonCube or the ZendOptimizer. I've followed multiple other tutorials and they all give me the same result -- a php.ini file & PATH that I need to "clean out."
If I have this much trouble trying to set it up just to learn to use it I HAVE ABSOLUTELY NO INTEREST in in doing it again when I want to actually deploy a project -- *IF* I even can.
Two years ago I had basically this same exact experience. I LOVE patterns & coding in PHP. I had a book I was very excited to work through, but it took a week just to get the framework to "seem" like it was working -- only to give me some esoteric errors that no one, not even the author, had any idea about when I finally got to the next page of the book.
You've turned my excitement about the Zend Framework into hatred. You should change you moto to something more like Ubuntu's -- "Zend Framework, it just doesn't work!"
<a href="http://www.rechtsanwalt-gelnhausen.com/">Versicherungsrecht</a>
<a href=http://www.aztechcouncil.org/>Arizona Women's Business</a>
Electronics or related categories if you can.
http://cellphonecontracts-blacklisted.co.za
but nothing solves this problem. The help documents contain NO info. THAT is the MAIN problem with zend!
Every process that involves properties, be them sales or simply letting contracts, take time and effort. You have a lot of walking to do and also a lot of waiting. We all know how many lines you will have to wait on until you are done. But with Edinburgh letting agents, you can skip yourself from that stress. I will now share with you some of the reasons why I think that everyone should use the services of this particular letting agency in Edinburgh.
Every step in this tutor is perfect the only thing missing here is you have to copy the folder /zendframework/library/Zend into yourapplication/library/
But the Tutorial is great and helps a lot to fix the things
Great work
<a href="http://www.dailynews.online102.com"> Daily News </a>
and make this open cart with the help of zend
<a href="http://www.sendflowers.online102.com">Send Flowers Online </a>
previously i use codeigniter and just one line of code and it start
running the framework that line of code is just a base path n that's it .
Just imagin in this framework i need to move file need to solve so many problmes
do this n that go here and there .
Just cant take it anymore.
It's great that people take the time to post how to do something any "computer person" in the business should know but really people? Get a clue..
If you are a programmer don't you feel you have the responsibility to at least understand how to configure the platform you are programming on? IG. Web Servers.....
Can you really support an application you have developed if you can't tell the client "hey you need to make this change on your server"... Or do you all just hand it off
and say "well it works for me"....
And yes you can drop zend into your site directory and not have to do all that config and adding to the system path crap.
http://akrabat.com/zend-framework/zend_loaders-autoloader_deprecated-in-zend-framework-18/
Get the code for the bootstrap index.php from here
http://www.killerphp.com/zend-framework/videos/zend-development-part-1.php
And then modify it using the second link and refer to the source files from the first link to see how to load a view.
I can't freakin believe I have to have a views/scripts/index.phtml and a views/myview.php just to load a view.
In codeigniter I'd just do this->load->view and it would load what ever view. Why is this so over complicated and yet so hard to find good howto info? Nettuts is starting a new zend from scratch series but the guy is doing it strictly for windows with the add to path junk.
<a href="http://flounderrecipes.net">Flounder recipes</a>
Mikael
The Herman Miller office furniture is very modern looking. The shapes of the chairs make them look very good. They sport smoothly bent lines and even all sorts of design on the sitting part. The colors are usually neutral colors that can be put just about anywhere. There are some exceptions like the Sayl Strawberry and Cream Edition chair. So if you need good looking chairs, then Herman Miller Office Chairs are what you need to make a good impression.
Thanks for the information.
PHP is also a part of the ZEND framework and there are lots of websites build with PHP, like this one http://pfeiffersymptomen.net is build with Wordpress which uses PHP too.
Cheers,
Michael Pfeiffer
PHP by Zend and ASP are the 2 biggest platforms for building websites nowadays.
These platforms are very populair.
Here are 2 examples:
PHP website: http://ijzertekort.net
ASP website: