Zend Framework Forum

Go Back   Zend Framework Forum > Zend Framework General discussions > General Q&A on Zend Framework

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-21-2008, 09:31 AM
Junior Member
 
Join Date: Jun 2008
Posts: 8
Default Making a CMS

Hi,

I'll make a CMS in PHP and I thought it could be saving me a lot of work to make it in ZF.

I don't really now how I should start on this as I never worked with ZF and I don't really understand how it's working. (I don't know every term (like for example a view helper and so one...) but I started making a directory structure and I don't know if this is the best structure for my CMS.

My CMS must have this features:
- Modular system
- Multiple themes (with different view files so the layout can be changed totally and not only with an other css file for example)

This is what I have now for the structure:
Code:
./application
        ./layouts
        ./modules
                ./module
                        ./controllers
                        ./models
                        ./views
./library
        ./Zend
./public
        ./images
        ./scripts
        ./styles
        ./index.php
Is this scruture good and does someone have any suggestions for me so I can make it better?

And this is my bootstrap:
[PHP]<?php
// Show every error
error_reporting(E_ALL | E_STRICT);
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);

// Add the zend library to the include path
set_include_path('../library' . PATH_SEPARATOR . get_include_path());

// Auto load every class we need
require_once "Zend/Loader.php";
Zend_Loader::registerAutoload();

// Load config
require_once 'config.php';
$config = new Zend_Config($config);
Zend_Registry::set('config', $config);

// Set up layout
$layout = Zend_Layout::startMvc(array(
'layout' => 'default',
'layoutPath' => '../application/layouts',
'contentKey' => 'content',
));

// DB connection
try {
$db = new Zend_Db_Adapter_Pdo_Mysql($config->database->params->toArray());
$db->getConnection();
Zend_Registry::set('dbConnection', $db);
} catch (Zend_Db_Adapter_Exception $e) {
echo 'Unexpected error!';
exit;
} catch (Zend_Exception $e) {
echo 'Unexpected error!';
exit;
}

// Error controller
$errorHandler = new Zend_Controller_Plugin_ErrorHandler();
$errorHandler->setErrorHandler(array('controller' => 'Error', 'action' => 'Error', 'module' => 'cms'));

// Set up front controller class
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(true);
$frontController->addModuleDirectory('../application/modules');
$frontController->setDefaultModule('index');
$frontController->registerPlugin( $errorHandler , 100 );
$frontController->setParam('noErrorHandler', true);
$frontController->dispatch();

// Quit page
$db->closeConnection();[/PHP]

Is this a good bootstrap?

Last edited by Juul; 06-21-2008 at 09:34 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-23-2008, 03:40 PM
Junior Member
 
Join Date: May 2008
Posts: 1
Default

Howdy,

I m making a similar thingy, here s the bootstrap used currently :
[PHP]
<?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 () );
}
[/PHP]

Some usefull inspirations :

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

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-23-2008, 03:50 PM
Junior Member
 
Join Date: Jun 2008
Posts: 8
Default

Thnx dude!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT. The time now is 02:59 AM.


Designed by: Miner Skinz Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0