zoukankan      html  css  js  c++  java
  • ZF学习使用之hello world

    ZF 1.11.2

    PHP 5.3

    创建虚拟站点httpd_vhost.conf

    <VirtualHost 192.168.1.106:80>
    <Directory "E:/www/zf">
    DirectoryIndex index.php
    AllowOverride all
    Options -Indexes FollowSymLinks
    </Directory>
    ServerAdmin coderzl@hotmail.com   
    DocumentRoot E:/www/zf/public
    ServerName zf.zaric.com
    ErrorLog "E:/www/logs/zf.localhost-error.log"
    CustomLog "E:/www/logs/zf.localhost-access.log" common
    </VirtualHost>

    /public/.htaccess

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$  /index.php/$1 [PT,L]

    工程目录结构:

    image

    创建index.php

    error_reporting(E_ALL | E_STRICT);            //设定Error Report的等级
    date_default_timezone_set('Asia/Taipei');    //设定时区为台北

    //Include path
    define ('P_S', PATH_SEPARATOR);
    set_include_path('.' .P_S .'../library' .P_S .'../application/models/' .P_S .get_include_path());
    require('Zend/Loader/Autoloader.php');
    Zend_Loader ::registerAutoload();

    image 

    最后一句提示:Zend_Loader::Zend_Loader::registerAutoload is deprecated as of 1.8.0 and will be removed with 2.0.0; use Zend_Loader_Autoloader,过期用Zend_Loader_Autoloader替代。

    下来

    Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true);//能够载入无名子空间的类,比如models目录下的类。
    $controller = Zend_Controller_Front::getInstance();
    $controller->setParam('useDefaultControllerAlways', true);
    $controller->setControllerDirectory('../application/controllers/');
    $controller->setBaseUrl('../application/controllers/');
    $controller->dispatch();

    建立:/application/controllers/IndexController.php

    class IndexController extends Zend_Controller_Action
    {
        function indexAction(){}

        function doAction(){}
    }

    同时建立:/application/views/script/index/index.phtml

    否则会报出异常:Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (error)

    最后运行:http://zf.zaric.com/index/index

    image

    http://zf.zaric.com/index/do

    image

    done!~

  • 相关阅读:
    矩形法求积分sin cos exp
    约瑟夫环问题
    KMP算法详解
    找出float型数组的最大值和最小值,分别和第一个和最后一个元素互换
    二重指针应用
    C++学习笔记(一)
    Line学习笔记
    node2vec学习笔记
    deepwalk学习笔记
    如何保证消息不被重复消费?(如何保证消息消费时的幂等性)
  • 原文地址:https://www.cnblogs.com/zaric/p/1957268.html
Copyright © 2011-2022 走看看