Kohana 3 route not matching

≯℡__Kan透↙ 提交于 2019-12-11 07:56:00

问题


Hi I am having problem while matching Kohana 3 custom route, it seems like every thing is correct but URL doesnot match with route. Following are settings in my bootstrap.php file:

   Kohana::init(array(
'base_url'   => '/basepath/',
    'index_file' => 'index.php'
  ));

  /**
  * 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
'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',
));

    Route::set('category_images', 'cat/<category>', array('category'=>'[a-z\-_\.]+'))
->defaults(array(
    'controller' => 'categoryimages',
    'action'     => 'index',
));

     Route::set('user_images', '<username>/images(/<pageid>)', array('username'=>'[a-z\-_\.]+', 'pageid'=>'[1-9][0-9]*'))
->defaults(array(
    'controller' => 'userimages',
    'action'     => 'index',
));




     Route::set('dynamic_image', 'image/thumbnail/<size>/<id>/<image>', array('size'=>'s|m|z', 'id'=>'[0-9]+', 'image'=>'.+'))
->defaults(array(
    'controller' => 'image',
    'action' => 'thumbnail'
));

Attached is the error mesage:

Here is target controller, to show naming conventions if there is problem in that:

<?php

class Controller_Categoryimages extends Controller_Template {

    public $template = 'template';
public $images_per_page = 15;

// show images of a user
    public function action_index() {
       //code here
     }

Please tell if some one have any idea that why it is not matching the URL.

thanks in advance guys.


回答1:


Your default route should be last, as it's a catch all. I'd recommend you delete it completely. It's currently matching default first, and trying to load the Contoller_Cat class with action sky.



来源:https://stackoverflow.com/questions/9711091/kohana-3-route-not-matching

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!