SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru risoknop's Avatar
    Join Date
    Feb 2008
    Location
    end($world)
    Posts
    834
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help noob install Zend framework

    SOLVED!

    Hello,

    I've decided to take a quick glance at Zend framework just out of curiosity. I have downloaded it and followed the 'QuickStart' tutorial.

    I have set the directory structure:

    Code:
    zend/
       application/
          controllers/
          views/
             scripts/
       library/
       public/
    I have downloaded and installed the framework, created index.php, bootstrap.php and .htaccess file with exact contents from the documentation, I have also set the document root to be 'public' directory.

    I have created an IndexController with indexAction + the view template index.phtml.

    I get this error when accessing http://localhost/

    Code:
    Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (error)' in E:\wamp\www\zend\library\Zend\Controller\Dispatcher\Standard.php:241 Stack trace: #0 E:\wamp\www\zend\library\Zend\Controller\Front.php(934): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 E:\wamp\www\zend\public\index.php(48): Zend_Controller_Front->dispatch() #2 {main} thrown in E:\wamp\www\zend\library\Zend\Controller\Dispatcher\Standard.php on line 241
    I've been trying to crack this problem for some while now but with no success. My brain is already too confused to think clearly so I humbly ask some Zend experts for help or some hint.

    I'm sure it's some trivial issue.
    Last edited by risoknop; Jan 3, 2009 at 18:18.

  2. #2
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try modifying the index.php to say

    Code:
    $zfApp->setEnvironment(’production’);
    or disable during development via

    Code:
    $controller->setParam('noErrorHandler', true);
    $controller->throwExceptions(true);
    Cross browser css bugs

    Dan Schulz you will be missed

  3. #3
    Use The Cloud
    Join Date
    Jan 2006
    Location
    Boise, ID
    Posts
    556
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When you have throwException set to false in your Front Controller, it forwards all application errors to ErrorController->errorAction(). This class would handle graceful error degrading and then show the user a friendly message, by default displayed by views/scripts/error/error.phtml

    If you set throwExceptions to true, then it won't forward to your error class and will instead dump the Exception directly to the browser.

    Typically this is set to false for production sites and true for development.
    Brad Hanson, Web Applications & Scalability Specialist
    ► Is your website outgrowing its current hosting solution?
    ► PM me for a FREE scalability consult!
    ► USA Based: Available by Phone, Skype, AIM, and E-mail.

  4. #4
    SitePoint Guru risoknop's Avatar
    Join Date
    Feb 2008
    Location
    end($world)
    Posts
    834
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is no object $zfApp in index.php. This is how the file looks (copypasted from documentation):

    PHP Code:
    <?php
    // public/index.php
    //
    // Step 1: APPLICATION_PATH is a constant pointing to our
    // application/subdirectory. We use this to add our "library" directory
    // to the include_path, so that PHP can find our Zend Framework classes.
    define('APPLICATION_PATH'realpath(dirname(__FILE__) . '/../application/'));
    set_include_path(
        
    APPLICATION_PATH '/../library' 
        
    PATH_SEPARATOR get_include_path()
    );

    // Step 2: AUTOLOADER - Set up autoloading.
    // This is a nifty trick that allows ZF to load classes automatically so
    // that you don't have to litter your code with 'include' or 'require'
    // statements.
    require_once "Zend/Loader.php";
    Zend_Loader::registerAutoload();

    // Step 3: REQUIRE APPLICATION BOOTSTRAP: Perform application-specific setup
    // This allows you to setup the MVC environment to utilize. Later you 
    // can re-use this file for testing your applications.
    // The try-catch block below demonstrates how to handle bootstrap 
    // exceptions. In this application, if defined a different 
    // APPLICATION_ENVIRONMENT other than 'production', we will output the 
    // exception and stack trace to the screen to aid in fixing the issue
    try {
        require 
    '../application/bootstrap.php';
    } catch (
    Exception $exception) {
        echo 
    '<html><body><center>'
           
    'An exception occured while bootstrapping the application.';
        if (
    defined('APPLICATION_ENVIRONMENT')
            && 
    APPLICATION_ENVIRONMENT != 'production'
        
    ) {
            echo 
    '<br /><br />' $exception->getMessage() . '<br />'
               
    '<div align="left">Stack Trace:' 
               
    '<pre>' $exception->getTraceAsString() . '</pre></div>';
        }
        echo 
    '</center></body></html>';
        exit(
    1);
    }


    // Step 4: DISPATCH:  Dispatch the request using the front controller.
    // The front controller is a singleton, and should be setup by now. We 
    // will grab an instance and call dispatch() on it, which dispatches the
    // current request.
    Zend_Controller_Front::getInstance()->dispatch();

  5. #5
    Use The Cloud
    Join Date
    Jan 2006
    Location
    Boise, ID
    Posts
    556
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Brad Hanson, Web Applications & Scalability Specialist
    ► Is your website outgrowing its current hosting solution?
    ► PM me for a FREE scalability consult!
    ► USA Based: Available by Phone, Skype, AIM, and E-mail.

  6. #6
    SitePoint Guru risoknop's Avatar
    Join Date
    Feb 2008
    Location
    end($world)
    Posts
    834
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK guys thanks for help. The problem was I have saved index.phtml to views/scripts/index/index/index.phtml (one 'index' folder more).


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •