GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Friday, January 21, 2011

The First App Using Zend

You need some steps:

1. Create folder structure
    - hello
      - application
        - controllers
        - models
        - views
          - filters
          - helpers
          - scripts
            - index
      - library
        - Zend
      - web_root
        - css
        - img
        - js  




2. Create .htaccess file in the web_root directory
RewriteEngine On
RewriteRule .* index.php


3. Create index.php file in the web_root directory
<?php

$root_dir = dirname( dirname(__FILE__) );
set_include_path( $root_dir . '/library' . PATH_SEPARATOR
    . get_include_path() );

require_once 'Zend/Controller/Front.php';
Zend_Controller_Front::run('../application/controllers');

?>

4. Create IndexController.php file inside hello/application/controllers directory:
<?php

require_once 'Zend/Controller/Action.php';

class IndexController extends Zend_Controller_Action
{
    public function indexAction()
    {
        $this->view->assign('title', 
                            'Hello from Zend framework');
    }
}

?>


5. Create index.phtml inside hello/application/views/scripts/index directory
<h1>Holla For You</h1>

<h1><?php echo $this->escape( $this->title); ?></h1>


6. Direct your browser to http://localhost/hello/web_root
Share/Bookmark

No comments:

Post a Comment