Étude comparative Zend Framework VS Genlist2

2011-11-26

=========================
genlist vs zend framework

Création
Genlist: interface web
Zend Framework:  ligne de commande (zf create project quickstart)
(quickstart = nom du répertoire du projet)


    quickstart
    |-- application
    |   |-- Bootstrap.php
    |   |-- configs
    |   |   `-- application.ini
    |   |-- controllers
    |   |   |-- ErrorController.php
    |   |   `-- IndexController.php
    |   |-- models
    |   `-- views
    |       |-- helpers
    |       `-- scripts
    |           |-- error
    |           |   `-- error.phtml
    |           `-- index
    |               `-- index.phtml
    |-- library
    |   |-- Zend (link to ZendFramework/library/Zend)
    |-- public
    |   |-- .htaccess
    |   `-- index.php
    `-- tests
        |-- application
        |   `-- bootstrap.php
        |-- library
        |   `-- bootstrap.php
        `-- phpunit.xml

// application/Bootstrap.php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap 
{
}

correspond à ??

// application/configs/application.ini
corresponds à php.ini + app/config/system.php

// application/controllers/IndexController.php
correspond à app/moddefault/index.php
public function init() { }  correspond à public function __construct()
public function indexAction() {} correspond à public function index(){}

// application/controllers/ErrorController.php
correspond à -> default/index.php (error_db, error_...)

$this->_getParam('error_handler') correspond à ???
$this->getResponse()->setHttpResponseCode(404) correspond à ???
$this->view->message = '' correspond à $this->_set('body','');
$this->view->exception=''; ???
 -> getMessage()
 -> getTraceAsString()
$this->view->request = ''; ???
  -> getParams()
$this->view->env ; development/production (voir application.ini)
$this->view->escape()

VirtualHost -> app/config/httpd.conf
SetEnv APPLICATION_ENV "development" <-- $this->view->env, $this->env

APPLICATION_PATH -> APP_PATH
APPLICATION_ENV -> <non>
public/index -> index.php with init.php
require_once 'Zend/Application.php' -> app/core/init.php
$application->bootstrap->run(); --> admin.php or else...

$this->url(array('controller'=>'guestbook'), 'default', true) --> _urlhtml('default','guestbook')
$this->url(array('controller'=>'guestbook','action'=>'sign'), 'default', true) --> _urlhtml('default','guestbook','sign')
$this->layout()->content -> $body

form:
$this->setMethod()
$this->setAction()
$this->addElement('type', 'name', array(label, required, filters, validators))
-> signAction -> $form = new Application_Form_Guestbook
getRequest()->isPost()
$form->isValid(getRequest()->getPost())
$array = $form->getValues()
$this->_helper->redirector('index') -> redirection
$this->view->form = $form





application/models/Guestbook.php -> app/modguestbook/Item
class Application_Model_Guesstbook() -> guestbook_ItemModel() 
setId() -> set_id()

class Application_Model_GuestbookMapper -> guestbook_ListModel
save() -> Item->insert_item(), Item->update_item()
find() -> Item->fetch_item()
fetchAll() -> List->toArray() (mais avec liste d'objet)

setId() -> return $this pour être enchainés


==> sqllite, loader...
zf create db-table Guestbook guestbook
application/models/DbTable/Guestbook
Application_Model_DbTable_Guestbook extends Zend_DbTable_Abstract
Zend_Db_Table -> 



application/views/scripts/index/index.phtml
correspond à app/moddefault/_index.php

dans les .phtml, tous est dans $this (correspond à $this->view)