• 最新zendframework1.11使用


    1、下载zf最新版Zend Framework- Downloads- Downloads

    2、首先进入cmd,命令行窗口模式。
    直接打下面的命令,
    C:\Documents and Settings\Administrator>E:\PHP\开源框架\ZendFramework-1.11.3\ZendFramework-1.11.3\bin\zf.bat create project D:\temp\zflearn
    3、C:\Documents and Settings\Administrator>d:  
    进入D盘
    D:\>cd temp\zflearn
    进入网站的目录
    D:\temp\zflearn>E:\PHP\开源框架\ZendFramework-1.11.3\ZendFramework-1.11.3\bin\zf.bat create module vote
    创建vote模型
    在D:\temp\zflearn\application\modules\vote\controllers下创建LoginController.php控制器
    同时也在D:\web\zf\application\modules\vote\views\scripts下生成视图 login\index.phtml
    D:\temp\zflearn>E:\PHP\开源框架\ZendFramework-1.11.3\ZendFramework-1.11.3\bin\zf.bat create controller login 1 vote
    如果后面不加1 vote
    则创建在D:\temp\zflearn\application\controllers
    D:\temp\zflearn\application\views\scripts下生成视图 login\index.phtml
    拷贝zend库
    将E:\PHP\开源框架\ZendFramework-1.11.3\ZendFramework-1.11.3\library 下的zend文件夹拷贝到
    在D:\temp\zflearn\library下

    附:网站整个目录不能有空格不然生成不成功

    index.php代码

    <?php

    // Define path to application directory
    defined('APPLICATION_PATH')
        || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/application'));
    defined('WEBROOT_PATH')
        || define('WEBROOT_PATH', realpath(dirname(__FILE__)));

    // 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(WEBROOT_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'
    );

    //$config=new Zend_Config_Ini(APPLICATION_PATH.'/configs/application.ini',null,true);
    //$db=Zend_Db::factory($config->general->db->adapter,$config->general->db->params->toArray());
    //Zend_Db_Table::setDefaultAdapter($db);
    $application->bootstrap()
                ->run();

    ?>

    Bootstrap.php

    <?php
    class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
    {
        protected function _initAutoload()
        {
            $loader = new Zend_Application_Module_Autoloader(array(
                'namespace' => '',
                'basePath' => APPLICATION_PATH));
            $loader->addResourceType('form', 'forms', 'Form')
                    ->addResourceType('model', 'models', 'Model')
                    ->addResourceType('dbtable', 'models/DbTable', 'Model_DbTable');
            // $loader->addResourceType('model', 'models',null);
            return $loader;       
        }
        protected function _initDB()
        {
            $options = $this->getOption('resources');
            $options = $options['db'];
            $resources = $this->getPluginResource('db');
            $db = $resources->getDbAdapter();
            Zend_Db_Table::setDefaultAdapter($db);
            //Zend_Registry::set('dbAdapter',$db);
            //Zend_Registry::set('dbprefix',$options['params']['prefix']);
        }
    }

    ?>

    application.ini

    [production]
    phpSettings.display_startup_errors = 1
    phpSettings.display_errors = 1
    includePaths.library = APPLICATION_PATH "/../library"
    includePaths.models = APPLICATION_PATH "/models/"
    bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
    bootstrap.class = "Bootstrap"
    appnamespace = "Application"
    resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
    resources.frontController.params.displayExceptions = 0
    resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
    resources.db.adapter =PDO_MYSQL
    resources.db.params.host ="192.168.0.1"
    resources.db.params.username ="root"
    resources.db.params.password ="123456"
    resources.db.params.dbname ="zflearn"
    resources.db.params.prefix =""
    resources.db.isDefaultTableAdapter = TRUE
    resources.db.params.driver_options.1002    = "SET NAMES UTF8;"
    [staging : production]

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

    [development : production]
    phpSettings.display_startup_errors = 0
    phpSettings.display_errors = 0
    resources.frontController.params.displayExceptions = 1

  • 相关阅读:
    java 基础语法 2
    hdu4570Multi-bit Trie
    poj1244Slots of Fun
    二维凸包模板
    花神的数论题(数位dp)
    poj1113Wall(凸包)
    poj1066Treasure Hunt(线段相交)
    poj1039Pipe(直线交点、叉积)
    hdu4588Count The Carries
    hdu2475Box(splay树形转线性)
  • 原文地址:https://www.cnblogs.com/witer666/p/1964134.html
Copyright © 2020-2023  润新知