+ Reply to Thread
Results 1 to 3 of 3

Thread: Making a CMS

  1. #1
    Juul is offline 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.

  2. #2
    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]
    <?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


  3. #3
    Juul is offline Junior Member
    Join Date
    Jun 2008
    Posts
    8

    Default

    Thnx dude!

+ Reply to Thread

Similar Threads

  1. Not making it through login controller
    By Dizzley in forum General Q&A on Zend Framework
    Replies: 1
    Last Post: 03-29-2010, 03:58 PM
  2. Making login data available to layout, etc.
    By Matt in forum Model-View-Controller (MVC)
    Replies: 3
    Last Post: 06-09-2009, 12:54 PM
  3. making dynamic links?
    By mally in forum General Q&A on Zend Framework
    Replies: 0
    Last Post: 02-04-2009, 03:50 PM
  4. Replies: 4
    Last Post: 09-19-2008, 07:59 AM
  5. Making index the default controller
    By americanu197 in forum Model-View-Controller (MVC)
    Replies: 3
    Last Post: 04-16-2008, 12:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts