Kohana 3.3你好世界不起作用

时间:2013-12-21 13:49:58

标签: php kohana kohana-3 kohana-3.3

导航到http://localhost:81/framework/时,我一直收到以下错误:

Kohana_HTTP_Exception [404]:在此服务器上找不到请求的网址框架。

enter image description here

我的控制器:

<?php defined('SYSPATH') OR die('No Direct Script Access');

Class Controller_Welcome extends Controller_Template
{
    public $template = 'site';

    public function action_index()
    {
        $this->template->message = 'hello, world!';
    }
}

我的 bootstrap.php 文件如下所示:

<?php defined('SYSPATH') or die('No direct script access.');

// -- Environment setup --------------------------------------------------------

/**
 * Initialize Kohana, setting the default options.
 *
 * The following options are available:
 *
 * - string   base_url    path, and optionally domain, of your application   NULL
 * - string   index_file  name of your index file, usually "index.php"       index.php
 * - string   charset     internal character set used for input and output   utf-8
 * - string   cache_dir   set the internal cache directory                   APPPATH/cache
 * - integer  cache_life  lifetime, in seconds, of items cached              60
 * - boolean  errors      enable or disable error handling                   TRUE
 * - boolean  profile     enable or disable internal profiling               TRUE
 * - boolean  caching     enable or disable internal caching                 FALSE
 * - boolean  expose      set the X-Powered-By header                        FALSE
 */
Kohana::init(array(
    'base_url'   => '/kohana/',
));

/**
 * Attach the file write to logging. Multiple writers are supported.
 */
Kohana::$log->attach(new Log_File(APPPATH.'logs'));

/**
 * Attach a file reader to config. Multiple readers are supported.
 */
Kohana::$config->attach(new Config_File);

/**
 * Enable modules. Modules are referenced by a relative or absolute path.
 */
Kohana::modules(array(
    // 'auth'       => MODPATH.'auth',       // Basic authentication
    // 'cache'      => MODPATH.'cache',      // Caching with multiple backends
    // 'codebench'  => MODPATH.'codebench',  // Benchmarking tool
    // 'database'   => MODPATH.'database',   // Database access
    // 'image'      => MODPATH.'image',      // Image manipulation
    // 'minion'     => MODPATH.'minion',     // CLI Tasks
    // 'orm'        => MODPATH.'orm',        // Object Relationship Mapping
    // 'unittest'   => MODPATH.'unittest',   // Unit testing
    // 'userguide'  => MODPATH.'userguide',  // User guide and API documentation
    ));

/**
 * Set the routes. Each route must have a minimum of a name, a URI and a set of
 * defaults for the URI.
 */
Route::set('default', '(<controller>(/<action>(/<id>)))')
    ->defaults(array(
        'controller' => 'welcome',
        'action'     => 'index',
    ));

我还尝试在以下目录中创建名为view的{​​{1}}: site.php

site.php

http://localhost/framework/application/views/site.php

当我导航到site.php时出现以下错误:

enter image description here

2 个答案:

答案 0 :(得分:1)

您需要在bootstrap.php(Kohana :: init部分中的/framework/)和.htaccess RewriteBase('base_url' => /framework/)RewriteBase /framework/) >

答案 1 :(得分:0)

问题出在basestrap.php我没有设置基本网址:

<强>之前:

Kohana::init(array(
    'base_url'   => '/kohana/',
));

<强>后:

Kohana::init(array(
    'base_url'   => '/framework/',
));