Follow the below steps and i assured you will got succeed for your first zend framework application.
Step 1 - Install zend framework :-
There are two ways to do this -
(a) Install zend server - Zend Server has native installers for Mac OSX, Windows, Fedora Core, and Ubuntu, as well as a universal installation package compatible with most Linux distributions.
After you have installed Zend Server, the Framework files may be found under /usr/local/zend/share/ZendFramework on Mac OSX and Linux, and C:\Program Files\Zend\ZendServer\share\ZendFramework on Windows. The include_path will already be configured .
to include Zend Framework.
(b) If you do not wants to install zend server then you can download zend library form Zend library latest and extract it where you wants in your PC.
Unpack the whole framework under a folder and add that folder/bin to you path.
So zend framework is installed on your computer now.
Test it on terminal (in Windows, Start -> Run, and then use cmd), type zf and press enter it should not show " 'zf' is not recognized as an interanl or external commnad, operable program or batch file."
If you got above error on your console then check you environment variable and add unpacked zend folder/bin to path variable now restart the console again and this error will not be longer visible.
Now you are ready for step two.
Step 2 - Create your project :-
Open a terminal (in Windows, Start -> Run, and then use cmd). Navigate to a directory where you would like to create a project. Then, use the path to the appropriate script, and execute following command:
"zf create project myproject"
after execution this command will create a folder myproject which structured like -
myproject
|-- .zfproject.xml
|-- application
|-- Bootstrap.php
|-- configs
|-- application.ini
|-- controllers
|-- ErrorController.php
|-- IndexController.php
|-- models
|-- views
|-- helpers
|-- scripts
|-- error
|-- error.phtml
|-- index
|-- index.phtml
|-- library
|-- public
|-- .htaccess
|-- index.php
|-- tests
|-- application
|-- bootstrap.php
|-- library
|-- bootstrap.php
|-- phpunit.xml
|-- public
|-- .htaccess
Step two is done, check your peoject path and its structure.
Step 3 - Create a virtual host :-
(We are using Apache web server(http://httpd.apache.org/) for this example.)
To create your vhost, you need to know the location of your httpd.conf file, and potentially where other configuration files are located.
C:\Program Files\Zend\Apache2\conf (Zend Server on Windows machines)
Define a virtual host in httpd.conf, you can use following reference if famalier with apache and php or just copy below
lines in httpd.conf
<VirtualHost *:8181>
ServerName localhost
DocumentRoot "/path/to/myproject/public"
SetEnv APPLICATION_ENV "development"
<Directory "/path/to/myproject/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
- replace /path/to/ with your created myproject path
- Don't forget to add Listen 8181 in httpd.conf
- Rewrite module should enabled in httpd.conf.
- DocumentRoot setting specifies the public subdirectory of our project; this means that only files under that directory can ever be served directly by the server.
- AllowOverride, Order, and Allow directives; these are to allow us to use htacess files within our project.
- The SetEnv directive. What we are doing here is setting an environment variable for your virtual host; this variable will be picked up in the index.php and used to set the APPLICATION_ENV constant for our Zend Framework application. In production, you can omit this directive (in which case it will default to the value "production") or set it explicitly to "production".
Start your webserver (or restart it), and you should be ready to go.
Type http://localhost:8181/ on your browser and if everthing is gone fine you will got zend welcome page.
If you got issue "....(Zend/Application.php) [function.require-once]: failed to open stream...." then put the Zend folder (within you downloaded \ZendFramework-version-blah\library\ ) right in the application directory you are using with (looks like it is \path\to\myproject\lirary).
Hope it well helpful for all Zend framework beginners.
Step 1 - Install zend framework :-
There are two ways to do this -
(a) Install zend server - Zend Server has native installers for Mac OSX, Windows, Fedora Core, and Ubuntu, as well as a universal installation package compatible with most Linux distributions.
After you have installed Zend Server, the Framework files may be found under /usr/local/zend/share/ZendFramework on Mac OSX and Linux, and C:\Program Files\Zend\ZendServer\share\ZendFramework on Windows. The include_path will already be configured .
to include Zend Framework.
(b) If you do not wants to install zend server then you can download zend library form Zend library latest and extract it where you wants in your PC.
Unpack the whole framework under a folder and add that folder/bin to you path.
So zend framework is installed on your computer now.
Test it on terminal (in Windows, Start -> Run, and then use cmd), type zf and press enter it should not show " 'zf' is not recognized as an interanl or external commnad, operable program or batch file."
If you got above error on your console then check you environment variable and add unpacked zend folder/bin to path variable now restart the console again and this error will not be longer visible.
Now you are ready for step two.
Step 2 - Create your project :-
Open a terminal (in Windows, Start -> Run, and then use cmd). Navigate to a directory where you would like to create a project. Then, use the path to the appropriate script, and execute following command:
"zf create project myproject"
after execution this command will create a folder myproject which structured like -
myproject
|-- .zfproject.xml
|-- application
|-- Bootstrap.php
|-- configs
|-- application.ini
|-- controllers
|-- ErrorController.php
|-- IndexController.php
|-- models
|-- views
|-- helpers
|-- scripts
|-- error
|-- error.phtml
|-- index
|-- index.phtml
|-- library
|-- public
|-- .htaccess
|-- index.php
|-- tests
|-- application
|-- bootstrap.php
|-- library
|-- bootstrap.php
|-- phpunit.xml
|-- public
|-- .htaccess
Step two is done, check your peoject path and its structure.
Step 3 - Create a virtual host :-
(We are using Apache web server(http://httpd.apache.org/) for this example.)
To create your vhost, you need to know the location of your httpd.conf file, and potentially where other configuration files are located.
C:\Program Files\Zend\Apache2\conf (Zend Server on Windows machines)
Define a virtual host in httpd.conf, you can use following reference if famalier with apache and php or just copy below
lines in httpd.conf
<VirtualHost *:8181>
ServerName localhost
DocumentRoot "/path/to/myproject/public"
SetEnv APPLICATION_ENV "development"
<Directory "/path/to/myproject/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
- replace /path/to/ with your created myproject path
- Don't forget to add Listen 8181 in httpd.conf
- Rewrite module should enabled in httpd.conf.
- DocumentRoot setting specifies the public subdirectory of our project; this means that only files under that directory can ever be served directly by the server.
- AllowOverride, Order, and Allow directives; these are to allow us to use htacess files within our project.
- The SetEnv directive. What we are doing here is setting an environment variable for your virtual host; this variable will be picked up in the index.php and used to set the APPLICATION_ENV constant for our Zend Framework application. In production, you can omit this directive (in which case it will default to the value "production") or set it explicitly to "production".
Start your webserver (or restart it), and you should be ready to go.
Type http://localhost:8181/ on your browser and if everthing is gone fine you will got zend welcome page.
If you got issue "....(Zend/Application.php) [function.require-once]: failed to open stream...." then put the Zend folder (within you downloaded \ZendFramework-version-blah\library\ ) right in the application directory you are using with (looks like it is \path\to\myproject\lirary).
Hope it well helpful for all Zend framework beginners.
Hi author,
ReplyDeleteIt's a nice attempt, expect a Hello world application which use any zend library from your part soon.
Regards
Anes
thanks for sharing nice post. we are coupon base website sharing huge collection of shopping coupon like InkFruit Coupon
DeleteHi amskape,
ReplyDeleteThanks for your valuable comments.
Any new body can also convert this application into zend's "Hello world" application.
Actually Zend create home page for us, when we using command line tool for create a new project.
If you wants to change this application as an Hello world application, then go to /path/to/myproject/application/views/scripts/index and replace the content of index.phtml with "Your content". Now it becomes a simple Hello world application.
Thanks a lot for the useful tips on Zend framework. I encourage you to write more useful posts on Zend.
ReplyDeleteZend is totally mess yaar. I want to learn MVC. I am amateur never have worked much on a core Object Oriented PHP. and bla bla bla...
ReplyDeleteThanks to you I solved error 403 :)
ReplyDeleteZend tutorials are weak (IMO), but Zend/Symfony is a must, at least where I live.
After checking several tutorials (including the official, the one from IBM and this) I am truly disappointed with Zend Framework. I think it is nearly impossible to install this framework, at least on Mac OS.
ReplyDeleteCan you post what problem you are facing? So we can help you
DeleteIt is just copy paste nothing else,people...
ReplyDeleteSorry, if i hurt your feelings but i did only simple the things. As Zend documentation is tough to understood for newbie. I tried here to explain their code in my language.
Deleteno me also face trouble for install still am not getting any one can helpme
ReplyDeleteIts better to specify problem what you are facing, so visitors can help you
DeleteThe framework is so sloppy that it's difficult to describe just a single problem in isolation. It's far from clear what any file or component of the framework does, or how/if it interacts with other files or components. Installation and setup worked for me, but now I have all this spaghetti all over my hard drive and the interdependencies within the framework are nowhere described. What a nightmare.
ReplyDeleteLearning with basic steps surely clear you till the end of ZEND.
Deletei am also facing problem to install, can anyone refer me any video for installation
ReplyDeleteBetter option is do it on xampp, and great enviroment for editing, and creating zend projects is zend studio
ReplyDeleteThis comment has been removed by the author.
ReplyDeletehello, I m not abe to how create view folder & not able to how create index file in zend framwork. please anyone may help me.
ReplyDeleteZend is an object oriented open-source software framework for building high quality Web Application speeds up the production and improves end user satisfaction. It can help the PHP developers to speed up the development and complete large development projects faster.
ReplyDeleteWeb development company in India | Managing Virtual Teams