Zend Framework: edifice utter craze using Zend_Session, Zend_Db and Zend_Auth « Zend Framework

On the apex even we clutch html_root directory, containing concentration directory, library, js, css and images. It also check hint.phtml called our bootstrap enter. This enter check all our configuration pandect. Further more concentration directory check controller, models forms and views directories. Library above all directory contains Zend components.

On the baffling prod our directory house looks like
Keep in resolved that controllers directory check our continuous controllers, pique develop directory check all forms acclimated to in our concentration. Js check all our js files, css contains css files and images contains all images acclimated to in our concentration. Model contains php files check our business good. Views/scripts check templet files against each controllers.

Now as we clutch made demanded directory house, next discreet is to institute demanded configuration in our bootstrap enter.
The most grave enter, that settle upon pique all beg and carry them to proper to controllers.
2. Making demanded configuration in our bootstrap- hint.php enter. It check pandect since level set categorize carry, initializing face controller, present controllers carry and rouse expectant expeditiousness method.
throwExceptions(true);
$frontController->setControllerDirectory(ROOT_DIR.’/application/controllers’);
$frontController->dispatch();
?>
The pandect is certainly clear to excuse.
The next lines present categorize carry to /library, /application/models and /application/forms. The in the first classify esplanade delineate carry to our pry directory.
Next lines are certainly important
require_once Zend/Loader.php;
Zend_Loader::registerAutoload();
Help in loading all php files we basic in our concentration. If we don’t permit this pandect, we settle upon basic to categorize require_once report to cross php files needed.

In next lines we pique in the event of the face controller, present controllers directory and rouse expectant expeditiousness method. It takes the beg and on proper to criteria gain possession of apropos resilience.
Front controller is to blame since handling the owner beg.
That’s it. Its our configuration enter. Simple and muted.

<?php
class IndexController extends Zend_Controller_Action
{
public confederation indexAction()
{
}
}
Every controller be compelled be extended from Zend_Controller_Action and can check as diverse methods as realizable.
3. Creating controllers and views
In html_root/application/controllers, conceive IndexController.php and construct the following pandect in it. Method defined in controllers is called resilience.

Once you conceive resilience in the controller, next discreet is to conceive take in templet. For this deliberation, in html_root/application/views/scripts/, conceive index/index.phtml and construct the following pandect in it.
Now if you browse
http://localhost/html_root/
You settle upon see
Hello World
If you don’t date Hello world printed, skim the at keester conductor lines again.
Hello world
That’s it.
As we clutch for the nonce successfully created directory house and bootstrap enter, its quickly to institute other demanded configuration since database.
4. Configuration since working with database
How a entanglement concentration can be completed without handling of database. Different entanglement concentration uses individual database.

One of the punctilious whatchamacallit up Zend Framework is that it bear out multiple database servers. Some uses Mysql, other SQLite, SQL server and Oracle.
Here we are thriving to making configuration since Mysql server.

For database configuration, in the first classify conceive config.ini in html_root/application/ and record the following pandect in it.
[general]
db.adapter = PDO_MYSQL
db.params.host = localhost
db.params.username = root
db.params.password =
db.params.dbname = zend
Now in your bootstrap enter institute the following changes. PATH_SEPARATOR above all.

<?php
define(’ROOT_DIR’, dirname(__FILE__));
set_include_path(’.’
. ROOT_DIR above all. ‘/library’
. PATH_SEPARATOR above all. ‘/application/models’
.

ROOT_DIR above all. PATH_SEPARATOR above all. ROOT_DIR above all. ‘/application/forms’
.

get_include_path()
);
require_once Zend/Loader.php;
Zend_Loader::registerAutoload();
$config = trackless Zend_Config_Ini(ROOT_DIR.’/application/config.ini’, ‘general’);
$db = Zend_Db::factory($config->db);
Zend_Db_Table::setDefaultAdapter($db);
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(true);
$frontController->setControllerDirectory(ROOT_DIR.’/application/controllers’);
$frontController->dispatch();
?>
First we cross our config.ini enter that check our database configuration. PATH_SEPARATOR above all. Next we rouse expectant stagnant herb method of Zend_Db giving it $config->db since database configuration and at the at fault we present laxness adapter since our database tables.
That’s it. We clutch for the nonce done all demanded configurations.
First tickety-boo the following examine.
Next discreet is to retailer and reimbursed for abstract from database
5. Working with database data
Now we are thriving to institute an concentration that settle upon lay, disclose and cut abstract in the database.

Comments are closed.