Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy can't i access the CakeRequest object from my class that extends AppController?
    primarykey
    data
    text
    <p>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. </p> <p>Here is my code (straight from the tutorial):</p> <pre><code>class PostsController extends AppController { public $helpers = array('Html', 'Form', 'Session'); public $components = array('Session'); ... public function add() { if ($this-&gt;request-&gt;is('post')) { ... } } } </code></pre> <p>here is the error page:</p> <pre><code>Notice (8): Undefined property: PostsController::$request [APP/controllers/posts_controller.php, line 16] Code public function add() { if ($this-&gt;request-&gt;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 </code></pre> <p>Thanks for any help you can provide.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload