Thread: Making a CMS
View Single Post
  #2 (permalink)  
Old 06-23-2008, 03:40 PM
fterrasson fterrasson is offline
Junior Member
 
Join Date: May 2008
Posts: 1
Default

Howdy,

I m making a similar thingy, here s the bootstrap used currently :
PHP Code:
<?php
/**
 *  blabla ...
 * @name Bootstrap
 * @package minisite
 * @author fabrice
 * @version v1.0
 *
 */

set_include_path (
    
'.' PATH_SEPARATOR 
    
'../library' PATH_SEPARATOR 
    
'../../../../library' PATH_SEPARATOR 
    
'../application/default/models/' PATH_SEPARATOR .
    
get_include_path () );

require_once 
'Zend/Controller/Front.php';
Zend_Loader::registerAutoload (); // pour ne pas ecrire xx lignes de loadClass()

date_default_timezone_set('Europe/Paris');

/*
 * données connexion BDD, layout, etc.
 */
$config = new Zend_Config_Ini '../application/default/config/config.ini''general' );

$registry Zend_Registry::getInstance ();
$registry->set 'config'$config );

/*
 * mise en place bdd
 */
try {
    
$db Zend_Db::factory $config->db );
    
Zend_Db_Table::setDefaultAdapter $db );
} catch ( 
Exception $e ) {
    exit ( 
$e->getMessage () );
}
Zend_Registry::set 'dbAdapter'$db ); // accessible partout

/*
 * Gestion des acces ressources
 */

$acl = new My_ACL ( ); //../library/My/ACL.php c'est automagique
Zend_Registry::set 'acl'$acl ); // accessible partout

/*
 * L'authentification 
 */
// durée de session
$storage = new Zend_Auth_Storage_Session ( );
$sessionNamespace = new Zend_Session_Namespace $storage->getNamespace () );
$sessionNamespace->setExpirationSeconds 600 ); // 10 min
// la session
$auth Zend_Auth::getInstance ();
$auth->setStorage $storage );
Zend_Registry::set 'auth'$auth );
// la gestion est definie dans le plugin My_PluginAuth

/**
 * Setup controller
 */
$controller Zend_Controller_Front::getInstance ();
$controller->setControllerDirectory '../application/default/controllers' );
$controller->throwExceptions TRUE ); // should be turned on in development time 

/*
 *  la gestion auth+acl est assurée par ../library/My/PluginAuth.php
 */
$controller->registerPlugin ( new My_PluginAuth $auth$acl ) );


/**
 * Router pour les chemins
 */
$router = new Zend_Controller_Router_Rewrite();
$router->addConfig( new Zend_Config_Ini('../application/default/config/routes.ini'null) );
$controller->setRouter($router);

/*
 * Layout à la MVC
 * application/default/layouts/layout.phtml est la presentation de toutes les pages
 * chaque vue est insérée ensuite a l'interieur
 */
Zend_Layout::startMvc $config->layout );

// run!
try {
    
$controller->dispatch ();
} catch ( 
Exception $e ) {
    echo 
nl2br $e->__toString () );
}
Some usefull inspirations :

More Example Zend Framework Blog madness Christer’s blog o’ fun

Codecaine.co.za / Codecaine.co.za now in SVN

Reply With Quote