Pages

Thursday, November 17, 2011

Zend Framework Module Setup.

To create modules in Zend Framework, need to create directory in this way:


 Zendapplication
   -- application
        -- modules
               --- default
                       --- controllers
                       --- models
                       --- views
               --- admin

                       --- controllers
                       --- models
                       --- views


        -- layouts
        -- Bootstrap.php
   -- library
  --  public
  -- index.php






After creating this structure , need to add some line application.ini or config.ini file



resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] = ""


for example: application.ini file



[production]
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.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] = ""


resources.frontController.params.displayExceptions = 0
resources.db.adapter = PDO_MYSQL
resources.db.params.host = localhost
resources.db.params.username = root
resources.db.params.password = 
resources.db.params.dbname = zend_db
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
;resources.layout = 'layout1'
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




Create a Bootstrap file in application/modules/default.


class Default_Bootstrap extends Zend_Application_Module_Bootstrap
{
 protected function _initAppAutoload()
        {
        $autoloader = new Zend_Application_Module_Autoloader(array(
        'namespace' => 'default',
        'basePath' => dirname(__FILE__). '/modules/default/'));
       return $autoloader;
     }

}


This will autoload to models, filters, helpers, etc... for our default module.




Also Create the file Bootstrap.php under your admin directory and add this code:

class Admin_Bootstrap extends Zend_Application_Module_Bootstrap
{
 protected function _initAppAutoload()
        {
        $autoloader = new Zend_Application_Module_Autoloader(array(
        'namespace' => 'admin',
        'basePath' => dirname(__FILE__). '/modules/admin/'));
       return $autoloader;
     }

}





Friday, November 11, 2011

How to append css file in zend?

Write given code in phtml file headLink()->appendStylesheet("css/style.css"); echo $this->headLink(); ?>

How to append javascript file in head tag of html in zend

Write below code in your phtml page. HeadScript()->appenfile("js/jquery.js"); echo $this->headScript(); ?>

Thursday, November 3, 2011

How to get register values or objects.

Exa : using get method of zend_Registry class we can get the registered values or objects. Exa: Zend_Registry::set('SITE_PATH'); Chears!

How to set global variable, values or objects in zend?

Ans: Zend registry is the container that is used to register global variable or value / object . Exa: Zend_Registry::set('SITE_PATH', ‘localhost/zendapp’); Chears!

Tuesday, October 25, 2011

Bootstrap Class

What is the role of bootstrap?

Bootstrap class defines what resources and component has to be initialized while loading the zend application.
By default front_controller is initialized.

How to use Doctype resource in zend?

- To use this doctype resource in the application we have to define doctype using view resource in the bootstrap class like


protected function _initDoctype()
{
        $this->bootstrap('view');
        $view = $this->getResource('view');
        $view->doctype('XHTML1_STRICT');
}


Now use at the top given line in the layout.phtml file. 
  echo $this->doctype() ?> 


Sunday, October 23, 2011

Why Should use zend framework?

Zend Framework is an open source application based on PHP 5. It has loosely coupled component library that can use more or less independently and MVC ( Model - View - Controller) architecture.

Zend Framework provides various features like

  1. Ajax
  2. seach
  3. Web servicec
  4. High-quality, object-oriented PHP 5 class library
  5. Syndication.

Please click here to download Zend Framework