Zend framework1.8

From EKiniWiki

Jump to: navigation, search

Contents

[edit] Zend Framework 1.8

Notes and quick references for the new Zend Framework 1.8.x releases.

[edit] .htaccess tips

This is useful so that you do not have to setup another virtual host and your Zend Framework directory structure will stay as is even on shared hosting.

RewriteEngine on
RewriteRule (.*) public/$1

Note: will only work with Apache and Rewrite Module on.

[edit] application.ini

Usually, we can setup this up like this:

[production]
;CSV PATH
;----------------------------------------------------
csv.path                           = "/webdata/csv"

;DATABASE SETTINGS
;----------------------------------------------------
resources.db.adapter               = "PDO_MYSQL"
resources.db.params.host           = "localhost"
resources.db.params.dbname         = "cssc_contractsdb"
resources.db.params.username       = "root"
resources.db.params.password       = "smoking"

;ZEND FRAMEWORK SETTINGS
;----------------------------------------------------
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"

resources.view[] =

;LDAP SETTINGS FOR AUTHENTICATION
;Note:
;to disable logging of user access in LDAP, remove the value in ldap.log_path
;----------------------------------------------------
ldap.log_path                   = /tmp/ldap.log
ldap.server1.host               = directory.my.website.com
ldap.server1.baseDn             = "o=Mysite"
ldap.server1.bindRequiresDn     = true
ldap.server1.accountFilterFormat = "(&(uid=%s))"


[staging : production]

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

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

[edit] Loading custom namespaces

We can do this for loading custom namespaces and registering plugins.

autoloaderNamespaces[] = "Wenbert_" ;load the Lexmark namespace
resources.frontController.plugins.CheckHasAcess = "Wenbert_Controller_Plugin_CheckHasAccess"

[edit] The Request Object

Zend_Debug::dump($this->_request->getPathInfo());
/**
 * Will output:
 *
 * string(32) "/mycontroller/myaction/param1/value1"
 *
 * From this URL:  http://mysite.com/mycontroller/myaction/param1/value1
 */

[edit] Getting values from a config file

$config = new Zend_Config_Ini('path/to/configs/application.ini', 'production');
echo $config->csv->path; //will echo "/path/to/my/csv/file"

If the config contains something like this:

;application.ini
[production]
;rest of the config data here...

csv.path = "/path/to/my/csv/file"

[staging : production]

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

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
Personal tools
Bookmarks