How to start Zend framework Reviewed by Momizat on . Structure of Zend Framework First download zend library from http://framework.zend.com/downloads/latest then create a structure according to below structure of Structure of Zend Framework First download zend library from http://framework.zend.com/downloads/latest then create a structure according to below structure of Rating: 0

How to start Zend framework

Structure of Zend Framework

First download zend library from http://framework.zend.com/downloads/latest
then create a structure according to below structure of image

zend framework

.htaccess file

SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

index.php file

<?php
// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/application'));

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path(),
)));

/** Zend_Application */
require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);


$application->bootstrap()
            ->run();
?>

application/configs/application.ini

Set database connection

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 1
phpSettings.date.timezone = "Europe/London"
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.defaultControllerName = "index"
resources.frontController.defaultAction = "index"
resources.frontController.params.displayExceptions = 0

resources.db.adapter = PDO_MYSQL
resources.db.params.host = localhost
resources.db.params.username ="XXXXXXXX"
resources.db.params.password ="XXXXXXXXX"
resources.db.params.dbname ="XXXXXXXXXX"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.view.doctype = "XHTML1_STRICT"

[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1


application/Bootstrap.php

<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
	public function _initview()
    {
        $view = new Zend_View($this->getOptions());
        Zend_Dojo::enableView($view);
        $view->doctype('XHTML1_STRICT');
        $view->headTitle()->setSeparator(' - ')->append('Sitetitle');
        $view->headMeta()->appendHttpEquiv('Content-Type','text/html; charset=iso-8859-1');
       return $view;
    }
	
}
?>

Other require files

Structure

  • Application
    • configs
      • application.ini
    • controllers
    • models
    • views
    • forms
    • layouts
    • Bootstrap.php
  • public
    • js
    • css
    • images
  • library
    • Zend
  • .htaccess
  • index.php

Leave a Comment

© 2014 Powered By