Posted by: james | June 8, 2009

How to start Zend framework

For ZENDFRAMEWROK first of all you have to get basic idea of php and you have to be clear with some basic funda of core php so you will get more interset in zend framework.  And if you have no idea about that then, please make some sense with it otherwise you will give up learning of zend framework. and after getting some idea about php get also some idea for MYSQL concepts i mean to say get some idea for INSERT,UPDATE,DELETE and all that queries so you will get more fun in zend framework.

in zend to load class there is two way.

1. use loadClass method od zend_loader class to load any class.

Zend_Loader::loadClass(‘class_name’);

ex: To load Zend_Db class,

Zend_Laoder::loadClass(‘Zend_Db’);

This is the bootstrap file or index.php looks like this as under so before start reading zend framework please make some sense with this though u don;t get anything.!!

<?php

//error_reporting(E_ALL|E_STRICT);
set_include_path(‘.’ . PATH_SEPARATOR . ‘./library’ . PATH_SEPARATOR . ‘./application/models/’ . PATH_SEPARATOR . get_include_path());
require_once ‘Zend/Controller/Front.php’;
require_once ‘Zend/Layout.php’;

Zend_Loader::loadClass(‘Zend_config_Ini’);
Zend_Loader::loadClass(‘Zend_Registry’);
Zend_Loader::loadClass(‘Zend_Db’);
Zend_Loader::loadClass(‘Zend_Db_Table’);

$config = new Zend_Config_Ini(‘./application/config.ini’,’general’);
$registry = Zend_Registry::getInstance();
$registry->set(‘config’,$config);

$db = Zend_Db::factory($config->db->adapter,$config->db->config->toArray());
Zend_Db_Table::setDefaultAdapter($db)

// Setup controller
$controller = Zend_Controller_Front::getInstance();
$controller->setControllerDirectory(‘./application/controllers’);
$controller->throwExceptions(false); // should be turned on in development time

// bootstrap layouts

Zend_Layout::startMvc(array(‘layoutPath’ => ‘./application/layouts’, ‘layout’ => ‘main’));

// run!
$controller->dispatch();

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: