2

申し訳ありませんが、これに関するチュートリアルがたくさんあることは知っていますが、試してみましたがうまくいきませんでした。

c: に WAMP をインストールしました。ドキュメント ルートは d:/Sites/Wamp です。そこから、通常の html、php、wordpress、および Code Igniter をロードできました。

Code Igniter を使用すると、ライブラリを d:/sites/Wamp フォルダーにコピー ペーストしてデータベースを構成するだけで済み、非常に簡単でした。

Zend フレームワークを使用して、いくつかのファイルを Wamp フォルダーにコピーするだけでよいようなことをしたいと思います。それは可能ですか?今のところ、Zend Tool の使用は避けたいと思います。チュートリアルまたはコピーするファイルを使用して、正しい方向に向けてください。

4

3 に答える 3

2

何らかの理由で Zend_Tool を使用したくない場合、デフォルトの基本的なアプリケーション構造は次のとおりです。

project
|-- application
|   |-- Bootstrap.php
|   |-- configs
|   |   `-- application.ini
|   |-- controllers
|   |   |-- ErrorController.php
|   |   `-- IndexController.php
|   |-- models
|   `-- views
|       |-- helpers
|       `-- scripts
|           |-- error
|           |   `-- error.phtml
|           `-- index
|               `-- index.phtml
|-- library
|   `--Zend //zend framework  goes here ***
|-- public
|   |-- .htaccess
|   `-- index.php
`-- tests
    |-- application
    |   `-- bootstrap.php
    |-- library
    |   `-- bootstrap.php
    `-- phpunit.xml

Zend Framework のダウンロードにlibraryフォルダーがあり、その中にフォルダーがありZendます。Zendフォルダー全体をコピーして、最終的に次のproject/libraryようになりますproject/library/Zend/

デフォルト.htaccessは次のようになり、public フォルダーに属します。

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

また、あなたのパブリックフォルダーにはあなたのものになり、次のindex.phpようになります。

<?php
//the next line is optional and is only to remove the index.php from the url
//$_SERVER["REQUEST_URI"] = str_replace('index.php', '', $_SERVER["REQUEST_URI"]);
// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// 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(APPLICATION_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'
);
$application->bootstrap()
            ->run();

でファイルproject/application/configs/がライブにapplication.iniなり、最初は次のようになります。

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0

[staging : production]

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

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

デフォルトBootstrap.phpは次のようになります。

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
}

デフォルトindexControllerは次のようになります。

class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        // action body
    }
}

最後に、デフォルトのエラー コントローラは次のようになります。

class ErrorController extends Zend_Controller_Action
{

    public function errorAction()
    {
        $errors = $this->_getParam('error_handler');

        switch ($errors->type) {
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:

                // 404 error -- controller or action not found
                $this->getResponse()->setHttpResponseCode(404);
                $this->view->message = 'Page not found';
                break;
            default:
                // application error
                $this->getResponse()->setHttpResponseCode(500);
                $this->view->message = 'Application error';
                break;
        }

        $this->view->exception = $errors->exception;
        $this->view->request   = $errors->request;
    }
}

http://localhost/project/publicこれで、Zend Framework アプリケーションへのすべてのリクエストが経由するURL でプロジェクトにアクセスできるようになりますindex.php

私は本当にお勧めしますZend_Tool、それは理由のために構築されました。

さらに必要な場合は... RTM これはすべてドキュメントに記載されています。

于 2013-05-09T07:36:54.323 に答える
0

http://akrabat.com/zend-framework-tutorial/にある Rob Allen のチュートリアルに従うことをお勧めします。これは、Zend Tool を使用してスケルトン アプリをセットアップすることを提案しますが、それをしたくないと言ったので、彼のサイトから完成したコードをダウンロードし、チュートリアルを読んでどのように組み立てられたかを確認できます。

于 2013-05-09T00:17:40.293 に答える