tags:

views:

150

answers:

2

I was just starting to learn cakephp today by going through a "blog tutorial". I created my blog_controller.php and then created a folder named 'blog' with the apps/views/ structure. The next step in the tutorial was to create the index.ctp file within the blog folder under views. In the tutorial it declares that all error messages should be gone. However, I still receive an error message:

Error: The view for BlogController::index() was not found.

Error: Confirm you have created the file: /Users/trippstephens/Dropbox/cakephp-cakephp1x-348e5f0/app/views/blog/index.ctp

For the life of me, I can not figure out what I have done wrong. I am running cakephp under MAMP and it "installed" successfully. Any help would be appreciated.

A: 

Looks like you have a couple of conventions issues going on here:

  1. Your controller should be plural: BlogsController with file name blogs_controller.
  2. Your views should exist in app/views/blogs/ (note the plural)

Your model should be singular (Blog), but that may already be the case (you don't include any model info).

Rob Wilkerson
A: 

I'm guessing that you don't really want a blog controller. Instead, you have your blog database with a posts table that contains all the blog posts you have. So, you would have /app/controllers/posts_controller.php and /app/views/posts/index.ctp.

Please refer to this: http://book.cakephp.org/view/23/File-and-Classname-Conventions for how CakePHP capitalizes and pluralizes your names.

erjiang