Русскоязычный форум, посвященный фреймворку Kohana

Все о фреймворке Kohana. Обсуждение уроков, документации.
Текущее время: 28 мар 2024, 16:59

Часовой пояс: UTC + 4 часа [ Летнее время ]




Начать новую тему Ответить на тему  [ Сообщений: 4 ] 
Автор Сообщение
 Заголовок сообщения: Изучаем Контроллер Welcome
СообщениеДобавлено: 12 фев 2012, 21:33 
Не в сети
Администратор
Аватара пользователя

Зарегистрирован: 12 фев 2012, 01:02
Сообщения: 462
В уроке происходит препарирование дефолтного контроллера. Если вдруг у вас что-то не срослось, пишите здесь.

_________________
kohanaframework.su - обучение фреймворку Kohana


Вернуться к началу
 Профиль  
 
 Заголовок сообщения: Re: Изучаем Контроллер Welcome
СообщениеДобавлено: 15 июл 2012, 02:26 
Не в сети
Зеленый

Зарегистрирован: 15 июл 2012, 02:17
Сообщения: 1
Здравствуйте!
Делаю как указано ниже >>>>>>


<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Welcome extends Controller {
public function action_index($name)
{
$this->response->body('hello, ' .$name);
}
} // End Welcome

хочу при вводе http://kohana/welcom/index/vasya
получить в IE текст >> hello, vasya
но получаю >>>>>>>>>
ErrorException [ Warning ]: Missing argument 1 for Controller_Welcome::action_index()
APPPATH\classes\controller\welcome.php [ 5 ]

1 <?php defined('SYSPATH') or die('No direct script access.');
2
3 class Controller_Welcome extends Controller {
4
5 public function action_index($name)
6 {
7 $this->response->body('hello, ' .$name);
8 }
9
10 } // End Welcome

APPPATH\classes\controller\welcome.php [ 5 ] » Kohana_Core::error_handler()

1 <?php defined('SYSPATH') or die('No direct script access.');
2
3 class Controller_Welcome extends Controller {
4
5 public function action_index($name)
6 {
7 $this->response->body('hello, ' .$name);
8 }
9
10 } // End Welcome

{PHP internal call} » Controller_Welcome->action_index()

SYSPATH\classes\kohana\request\client\internal.php [ 118 ] » ReflectionMethod->invoke(arguments)

0 object Controller_Welcome(2) {
public request => object Request(21) {
protected _requested_with => NULL
protected _method => string(3) "GET"
protected _protocol => string(8) "HTTP/1.1"
protected _secure => bool FALSE
protected _referrer => NULL
protected _route => object Route(5) {
protected _callback => NULL
protected _uri => string(32) "(<controller>(/<action>(/<id>)))"
protected _regex => array(0)
protected _defaults => array(2) (
"controller" => string(7) "welcome"
"action" => string(5) "index"
)
protected _route_regex => string(95) "#^(?:(?P<controller>[^/.,;?\n]++)(?:/(?P<action>[^/.,;?\n]++)(?:/(?P<id>[^/.,;?\n]++))?)?)?$#uD"
}
protected _routes => NULL
protected _response => object Response(5) {
protected _status => integer 200
protected _header => object HTTP_Header(0) {
}
protected _body => string(0) ""
protected _cookies => array(0)
protected _protocol => string(8) "HTTP/1.1"
}
protected _header => object HTTP_Header(0) {
}
protected _body => NULL
protected _directory => string(0) ""
protected _controller => string(7) "welcome"
protected _action => string(5) "index"
protected _uri => string(19) "welcome/index/Vasya"
protected _external => bool FALSE
protected _params => array(1) (
"id" => string(5) "Vasya"
)
protected _get => array(0)
protected _post => array(0)
protected _cookies => array(0)
protected _client => object Request_Client_Internal(2) {
protected _previous_environment => NULL
protected _cache => NULL
}
public _injected_routes => array(0)
}
public response => object Response(5) {
protected _status => integer 200
protected _header => object HTTP_Header(0) {
}
protected _body => string(0) ""
protected _cookies => array(0)
protected _protocol => string(8) "HTTP/1.1"
}
}


113 throw new HTTP_Exception_404('The requested URL :uri was not found on this server.',
114 array(':uri' => $request->uri()));
115 }
116
117 $method = $class->getMethod('action_'.$action);
118 $method->invoke($controller);
119
120 // Execute the "after action" method
121 $class->getMethod('after')->invoke($controller);
122 }
123 catch (Exception $e)

SYSPATH\classes\kohana\request\client.php [ 64 ] » Kohana_Request_Client_Internal->execute_request(arguments)

0 object Request(21) {
protected _requested_with => NULL
protected _method => string(3) "GET"
protected _protocol => string(8) "HTTP/1.1"
protected _secure => bool FALSE
protected _referrer => NULL
protected _route => object Route(5) {
protected _callback => NULL
protected _uri => string(32) "(<controller>(/<action>(/<id>)))"
protected _regex => array(0)
protected _defaults => array(2) (
"controller" => string(7) "welcome"
"action" => string(5) "index"
)
protected _route_regex => string(95) "#^(?:(?P<controller>[^/.,;?\n]++)(?:/(?P<action>[^/.,;?\n]++)(?:/(?P<id>[^/.,;?\n]++))?)?)?$#uD"
}
protected _routes => NULL
protected _response => object Response(5) {
protected _status => integer 200
protected _header => object HTTP_Header(0) {
}
protected _body => string(0) ""
protected _cookies => array(0)
protected _protocol => string(8) "HTTP/1.1"
}
protected _header => object HTTP_Header(0) {
}
protected _body => NULL
protected _directory => string(0) ""
protected _controller => string(7) "welcome"
protected _action => string(5) "index"
protected _uri => string(19) "welcome/index/Vasya"
protected _external => bool FALSE
protected _params => array(1) (
"id" => string(5) "Vasya"
)
protected _get => array(0)
protected _post => array(0)
protected _cookies => array(0)
protected _client => object Request_Client_Internal(2) {
protected _previous_environment => NULL
protected _cache => NULL
}
public _injected_routes => array(0)
}


59 public function execute(Request $request)
60 {
61 if ($this->_cache instanceof HTTP_Cache)
62 return $this->_cache->execute($this, $request);
63
64 return $this->execute_request($request);
65 }
66
67 /**
68 * Processes the request passed to it and returns the response from
69 * the URI resource identified.

SYSPATH\classes\kohana\request.php [ 1138 ] » Kohana_Request_Client->execute(arguments)

0 object Request(21) {
protected _requested_with => NULL
protected _method => string(3) "GET"
protected _protocol => string(8) "HTTP/1.1"
protected _secure => bool FALSE
protected _referrer => NULL
protected _route => object Route(5) {
protected _callback => NULL
protected _uri => string(32) "(<controller>(/<action>(/<id>)))"
protected _regex => array(0)
protected _defaults => array(2) (
"controller" => string(7) "welcome"
"action" => string(5) "index"
)
protected _route_regex => string(95) "#^(?:(?P<controller>[^/.,;?\n]++)(?:/(?P<action>[^/.,;?\n]++)(?:/(?P<id>[^/.,;?\n]++))?)?)?$#uD"
}
protected _routes => NULL
protected _response => object Response(5) {
protected _status => integer 200
protected _header => object HTTP_Header(0) {
}
protected _body => string(0) ""
protected _cookies => array(0)
protected _protocol => string(8) "HTTP/1.1"
}
protected _header => object HTTP_Header(0) {
}
protected _body => NULL
protected _directory => string(0) ""
protected _controller => string(7) "welcome"
protected _action => string(5) "index"
protected _uri => string(19) "welcome/index/Vasya"
protected _external => bool FALSE
protected _params => array(1) (
"id" => string(5) "Vasya"
)
protected _get => array(0)
protected _post => array(0)
protected _cookies => array(0)
protected _client => object Request_Client_Internal(2) {
protected _previous_environment => NULL
protected _cache => NULL
}
public _injected_routes => array(0)
}


1133 throw new Request_Exception('Unable to execute :uri without a Kohana_Request_Client', array(
1134 ':uri' => $this->_uri,
1135 ));
1136 }
1137
1138 return $this->_client->execute($this);
1139 }
1140
1141 /**
1142 * Returns whether this request is the initial request Kohana received.
1143 * Can be used to test for sub requests.

DOCROOT\index.php [ 109 ] » Kohana_Request->execute(

ПОМОГИТЕ ПОЖАЛУЙСТА!


Вернуться к началу
 Профиль  
 
 Заголовок сообщения: Re: Изучаем Контроллер Welcome
СообщениеДобавлено: 27 июл 2012, 20:00 
Не в сети
Администратор
Аватара пользователя

Зарегистрирован: 12 фев 2012, 01:02
Сообщения: 462
Жесть. А можно как-то в теги завернуть? И кода поменьше.

_________________
kohanaframework.su - обучение фреймворку Kohana


Вернуться к началу
 Профиль  
 
 Заголовок сообщения: Re: Изучаем Контроллер Welcome
СообщениеДобавлено: 29 июл 2012, 15:23 
Не в сети
Бывалый

Зарегистрирован: 16 апр 2012, 19:44
Сообщения: 113
Не правильно пытаетесь получить переменную.
При стандартном роуте должно быть как-то так

Код:
public function action_index()
 {
$name = $this->request->param('id');
 $this->response->body('hello, ' .$name);
 }


Вернуться к началу
 Профиль  
 
Показать сообщения за:  Поле сортировки  
Начать новую тему Ответить на тему  [ Сообщений: 4 ] 

Часовой пояс: UTC + 4 часа [ Летнее время ]


Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 7


Вы не можете начинать темы
Вы не можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете добавлять вложения

Найти:
Перейти:  
cron
Все о фреймворке Kohana  | 
Powered by phpBB® Forum Software © phpBB Group