Why does cakePHP complain that $request is undefined? I was following the tutorial that they have up on their site how to make a blog (the hello work of frameworks) and I had been fixing the various errors that i came across in the tutorial code (I figured the tutorial was a little bit out of date) but here is one I haven't been able to fathom. Looking at the api documentation it says that Controller has a $request property. my PostsController extends AppController which extends Controller, so it would make sense that it would have the $requests property, but it doesn't, not even according to print_r.
Here is my code (straight from the tutorial):
class PostsController extends AppController {
public $helpers = array('Html', 'Form', 'Session');
public $components = array('Session');
...
public function add() {
if ($this->request->is('post')) {
...
}
}
}
here is the error page:
Notice (8): Undefined property: PostsController::$request [APP/controllers/posts_controller.php, line 16]
Code
public function add() {
if ($this->request->is('post')) {
PostsController::add() - APP/controllers/posts_controller.php, line 16
Object::dispatchMethod() - CORE/cake/libs/object.php, line 116
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 227
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 194
[main] - APP/webroot/index.php, line 88
Fatal error: Call to a member function is() on a non-object in shared/THS/test/www/MyCake/app/controllers/posts_controller.php on line 16
Thanks for any help you can provide.