Zend Framework Tutorial
|
|
|
Click to rate: |
|
|
|
1,076 votes / avg. rating 33.42%
|
|
We asked PHP security expert — and contributor to the newly-released Zend Framework — Chris Shiflett to write an article for us on the ZF's major features, and he came through with style! This complete, step-by-step tutorial provides an exclusive first look at building a practical application with the framework by showing you how to write a simple news management system.
The Zend Framework has been unveiled! Although it is still in the early stages of development, this tutorial highlights some ofthe best of what's available now and guides you through the process of building a simple application. Zend has chosen to release the framework and involve the community early. In the same spirit, this tutorial is written to showcase the framework as it exists today. Because this tutorial is published online, I'll update it as the framework evolves, so that it remains relevant as long as possible. RequirementsThe Zend Framework requires PHP 5. In order to take full advantage of the code presented in this tutorial, you also need the Apache web server, because the sample application (a news management system) uses mod_rewrite.
The code from this tutorial is available for free download, so you can try it out for yourself. You can download it from the Brain Bulb web site at http://brainbulb.com/zend-framework-tutorial.tar.gz. Downloading the FrameworkBefore you can get started with this tutorial, you need to download the preview release of the framework. You can do this manually by visiting http://framework.zend.com/download with a browser and choosing the tar.gz or zip download, or you can use the command line:
$ wget http://framework.zend.com/download/tgz
$ tar -xvzf ZendFramework-0.1.2.tar.gz
NoteZend has plans to offer its own PEAR channel to help simplify the download process. Once you have the preview release, locate the library directory and place it somewhere convenient. In this tutorial, I rename library to lib to provide a clean and simple directory structure:
app/
views/
controllers/
www/
.htaccess
index.php
lib/
The www directory is the document root, controllers and views are empty directories you'll use later, and the lib directory is from the preview release download.Getting StartedThe first component I want to show you is Zend_Controller. In many ways, it provides the foundation of the application you're developing, and it's also part of what makes the Zend Framework more than just a collection of components. Before you can use it, however, you need to direct all incoming requests to a single PHP script. This tutorial uses mod_rewrite for this purpose.
Using mod_rewrite is an art in itself, but luckily, this particular task is very simple. If you're unfamiliar with mod_rewrite or configuring Apache in general, create a .htaccess file in the document root and add the following directives:
RewriteEngine on
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
One of the TODO items for Zend_Controller is to remove the mod_rewrite dependency. In order to provide an example that works with the preview release, this tutorial uses mod_rewrite. If you add these directives to httpd.conf directly, you must restart the web server. Otherwise, if you use a .htaccess file, you should be good to go. You can quickly test this by placing some identifiable text in index.php and making a request for an arbitrary path, such as /foo/bar. For example, if your host is example.org, request the URL http://example.org/foo/bar.You also want include_path to include the path to the framework library. You can do this in php.ini, or you can just put the following directive in your .htaccess file:
php_value include_path "/path/to/lib"
ZendThe Zend class contains a collection of static methods that are universally useful. This is the only class you must include manually:
<?php
include 'Zend.php';
?>
Once you've included Zend.php, you have access to all of the methods from the Zend class. Loading other classes is simplified with the loadClass() method. For example, to load the Zend_Controller_Front class:
<?php
include 'Zend.php';
Zend::loadClass('Zend_Controller_Front');
?>
The loadclass() method is include_path-aware, and it also understands the organization and directory structure of the framework. I use it to load all other classes.
 |
|
 |
|
Tags:
test, php, dd, tutorial, anup uk, shiflet, shiflett, zend, framework, web, site, anirudha, fdffffffffffffff, hello world, httpwwwgooglecom, kjkljlkj, asasas, vinod, chilli, shiflettasshat, mama, papa, chuckoo, sathishan, nithyan, ashokan, unni, divya, pradeep, abcphp, zde, jayesh jose, harro, ronnie, sample, oui, lebicheur, controller, error, d, kontrola, omg lol, 5, 46457, dfsdfdsf, sdfsdf, asd, crazy, booga, should tags be allowed to be added like this, no i dont think so the tags should be extracted from content, dont allow users to add tags or youll see the results, tags are the root of all evil, thi is, cvcxv, ioncube, zend framework, you already see the results, has not printable version, user created tags how lame, pet the monkey, shoutmouthcom, maybe only registered users should be able to add tags, adding another worthless tag to hammer in the points made earlier, this is only way to add new tag, didip is a complete bonehead, rapdwordpresscom, trke olmayan dkman, turkce olmayan dokumanlar, prova, anytagiwant, bump, wtf, transformers more than meets the eye, this seems like a really bad idea for some reason even though the implementation is reasonably cool, bullshitbingo, fukoka, h, lol, if it has tags on it it must be web20 and therefore cool, ooh look ajax, mike was here, gfgf, doogii, kkkk, annoying, prueba, hjkhklhkjhkjhjk, hi i want to have my own tag here too, oo, what an odd idea to have your own tags for unregistered users ajax, my tag too , xminds, soooo bad that everyone can add tags unmanaged , spam , w00000000t, o0, bottledpuppiesforsalecom, ciao mondo, lollerskates, user added tagshow lame, i agree with what other people are saying guests shouldnt be allowed to add tags, i have a penis, fala serio what a bad idea , cccccc, im2combr, a hrefhttpwwwim2combrcriao de sitesa, wow, good, beep, chick, bleep, stix, mix, fix, this, jesuswillsaverockstarstoo, loldongs, i like it, this is dumb, anyone can tag any article go to my portsite bitchescom, testitest, oh nos its a tarp, hmmm, lets try, what, someone really ought to clean up these tags its a waste of space and an eyesore
Tags Help
Tags are keywords associated with a web page that help classifying information. You can find a good explanation here.
To add one or more tags to this page, simply enter them below (separate them with a comma) and hit enter or click on the "Go" button.
|
|
 |
|
 |
|
Index
|