I'm following the cakePHP "getting started" here:
http://book.cakephp.org/2.0/en/getting-started.html
One thing I got stuck on is that I created the model, controller, and view for Posts eg:
<docroot>/app/Controller/PostsController.php
<docroot>/app/Model/Post.php
<docroot>/app/View/Posts/index.ctp
exactly as outlined in the link above. The problem is that I was getting the error:
Error: PostsController could not be found.
And the Controller code was being printed at the top of the page.
I finally figured out that I had to add
<?php [code] ?>
around the code that the tutorial specified for the controller file. ie intstead of:
class PostsController extends AppController {
public $helpers = array('Html', 'Form');
public function index() {
$this->set('posts', $this->Post->find('all'));
}
}
I had:
<?php
class PostsController extends AppController {
public $helpers = array('Html', 'Form');
public function index() {
$this->set('posts', $this->Post->find('all'));
}
}
?>
Once I did that, it worked, kinda. Except then I was getting the model "code" printed at the top of the page. Surrounding that with the php escape (as in the controller above) resolved that issue, but I'm concerned that this is hinting that I've misconfigured something while setting up cake.
My question: is the tutorial wrong? Why would it not specify the use of the php escapes (or whatever you call those things) if they are needed to get this stuff working? Or, if they should not be needed, can anyone suggest a reason that in my case they are needed? Maybe I've mis-configured something before this step...
Thanks, I looked for a similar question on SO but was unable to locate one, but please feel free to direct me if this is a duplicate...