2015-01-07 1 views
1

Я пытаюсь создать свой первый веб-страницу Kohana, с помощью этого учебника - http://kohana-tutorial.blogspot.co.uk/2010/10/lesson-1-getting-started.html

После выполнения инструкции, я остался с этой ошибкой - Не определено свойство: Запрос :: $ действие на линии 49.

Это код, связанный с этим линии, в DefaultTemplate.php

48 if (!$view){ 
49  $view = 'pages/'.$this->request->controller().'/'.$this->request->action.'_tpl'; 
50  } 
51  $this->template->content = View::factory($view, $this->data); 
52 } 
53 } 
54 ?> 

Это вызывается news.php, который представляет собой стандартный вызов, чтобы сделать что-то.

class Controller_News extends Controller_DefaultTemplate { 
    public function __construct(\Request $request, \Response $response) { 
     parent::__construct($request, $response); 
    } 
    public function action_index(){ 
     $this->render(); 
    } 
} 

Полный список программ, которые используются, чтобы добраться до этой ошибки:

APPPATH/classes/Controller/DefaultTemplate.php [ 49 ] » Kohana_Core::error_handler(arguments) 
APPPATH/classes/Controller/News.php [ 13 ] » Controller_DefaultTemplate->render() 
SYSPATH/classes/Kohana/Controller.php [ 84 ] » Controller_News->action_index() 
{PHP internal call} » Kohana_Controller->execute() 
SYSPATH/classes/Kohana/Request/Client/Internal.php [ 97 ] » ReflectionMethod->invoke(arguments) 
SYSPATH/classes/Kohana/Request/Client.php [ 114 ] » Kohana_Request_Client_Internal- >execute_request(arguments) 
SYSPATH/classes/Kohana/Request.php [ 997 ] » Kohana_Request_Client->execute(arguments) 
DOCROOT/index.php [ 118 ] » Kohana_Request->execute()APPPATH/classes/Controller/News.php [ 13 ] » Controller_DefaultTemplate->render() 
SYSPATH/classes/Kohana/Controller.php [ 84 ] » Controller_News->action_index() 
{PHP internal call} » Kohana_Controller->execute() 
SYSPATH/classes/Kohana/Request/Client/Internal.php [ 97 ] » ReflectionMethod->invoke(arguments) 
SYSPATH/classes/Kohana/Request/Client.php [ 114 ] » Kohana_Request_Client_Internal->execute_request(arguments) 
SYSPATH/classes/Kohana/Request.php [ 997 ] » Kohana_Request_Client->execute(arguments) 
DOCROOT/index.php [ 118 ] » Kohana_Request->execute() 

Любая помощь будет с благодарностью получил.

ответ

1

Этот урок 4 года, поэтому он, вероятно, немного устарел.

С текущей версии Кохана, Вы можете получить доступ к защищенным ресурсам $request->_action следующим:

$this->request->action(); 

Не стесняйтесь проверить online documentation или даже исходный код в system/classes/Kohana, который ясно и хорошо прокомментировал.

 Смежные вопросы

  • Нет связанных вопросов^_^