Kohana : Kohana_HTTP_Exception [ 404 ]: The requested URL calendar was not found on this server

StackOverflow https://stackoverflow.com/questions/18264098

  •  24-06-2022
  •  | 
  •  

Вопрос

I'm learning kohana and I'm using ver:3.3.0.

I'm getting this error:

Kohana_HTTP_Exception [ 404 ]: The requested URL calendar was not found on this server.
SYSPATH\classes\Kohana\Request\Client\Internal.php [ 79 ]

SYSPATH\classes\Kohana\Request\Client\Internal.php [ 79 ]
SYSPATH\classes\Kohana\Request\Client.php [ 114 ] » Kohana_Request_Client_Internal->execute_request(arguments)
SYSPATH\classes\Kohana\Request.php [ 990 ] » Kohana_Request_Client->execute(arguments)
DOCROOT\index.php [ 118 ] » Kohana_Request->execute() 

URL I type in:

(//localhost/organizer_tst/calendar/)

My files:

application\classes\Controller\Calendars\Calendar.php:

class Controller_Calendar extends Controller
{

    public function action_index()
    {
        $tst = new Model_Calendar();
               echo $tst->testing("LOLLOLOOLL");              
    }
}

application\classes\Model\calendar.php:

Class Model_Calendar extends Model
{
    public function testing($param)
    {
        $tst ="I want to display it: "."$param";
        return $tst ;        
    }   
}

bootstrap.php:

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

Route::set('something', 'calendar(/<directory>(/<controller>(/<action>(/<id>))))')
    ->defaults(array(
        'directory'  => 'Calendars',
        'controller' => 'Calendar',
        'action'     => 'index',
    ));

Route::set('default', '(<controller>(/<action>(/<id>)))')
    ->defaults(array(
        'controller' => 'welcome',
        'action'     => 'index',
    ));

I checked "Environment->included files" on error page I can see my controller file: APPPATH\classes\Controller\Calendars\Calendar.php

Everything is working if Controller is not in an extra directory in this case : application\classes\Controller\Calendars\Calendar.php

I use Xampp my root directory: D:\xampp\htdocs and I have alias to my project: Alias /organizer_tst/calendar "D:\xampp\htdocs\organizer_tst"

Can you please tell me why I have this error exception?

Это было полезно?

Решение

Kohana's naming conventions tell you how you should name and locate your classes.

In this case Kohana is looking for a class named Controller_Calendars_Calendar in location application/classes/Controller/Calendars/Calendar.php. It finds the file but not the class. You should name your class Controller_Calendars_Calendar or move the file to application/classes/Controller/Calendar.php

Другие советы

COntroller: blog.php In blog.php there is a method defined as follows:

public function action_new()
    {
        $view =View::factory('blog/new');
        $this->response->body($view);
    }

views:A folder named "Blog" and inside blog you have a file named new.php

Check your files in this sequence.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top