Monday, 18 March 2013

How to Install Zend Framework



Create 3 directory in your project directory i.e.  application, library and public

after that follow the following steps -

1. download the latest library file for zend and paste the library's zend folder in library section.
2. create the following folder in the application folder -
                configs, controllers, models, views, forms, layouts

3. create a index.php in the public folder and paste the following code
 --------------------------------Start Index.php ------------------------------------------------------------
<?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();


------------------------------------------- End of Index.php---------------------------------------------


4. create a .htaccess file in the public folder

------------------  .htaccess --------------------------

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]

---------------------- End of file ---------------------------------------


5.       create a Bootstrap.php file in the application folder

--------------  Bootstrap.php -----------------

<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{


}

------------------- End of file ----------------


6. create a application.ini file in the configs folder

-----------------------  application.ini -------------------

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
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.params.displayExceptions = 0
resources.db.adapter = PDO_MYSQL
resources.db.params.host = localhost
resources.db.params.username = root
resources.db.params.password = root
resources.db.params.dbname = zf-tutorial
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.view.doctype = "XHTML1_STRICT"

resources.db.params.profiler.enabled    = true
resources.db.params.profiler.class      = Zend_Db_Profiler_Firebug

[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
phpSettings.error_reporting = -9



No comments:

Post a Comment