CakePHP Naming Conventions

CakePHP requires us to follow certain convention. In this way, we will have very uniform system development, have free functionality, and save time over tracking configuration files! :)1. Create a Model 

  • directory: app/models/
  • filename: post.php 
  • classname: Post
  • extension: class Post extends AppModel

The filenames of models are always singular. And its classnames are CamelCased.

2. Create a Controller 

  • directory: app/controllers/
  • filename: posts_controller.php
  • classname: PostsController
  • extension: class PostsController extends AppController

The filename of a controller is always plural followed by an underscore then the word "controller" (_controller). Classnames are also CamelCased.

3. Creat a View

  • directory: app/views/posts/
  • filename: hello_world.ctp

You will create another view directory for each of your models. In this case, we created a directory called "posts" under app/views/ directory. Filenames are saved with the extension .ctp (I believe its "cake template page"). They are also named after the method/function (action) inside your controller.

If you have more than one word object (ex. Sponsored Member), you may use underscores to name it. In my case, I will name it "sponsored_member".

Model: sponsored_member.php
View: app/views/sponsored_members
Controller: sponsored_members_controller.php

How To Alter/Change InnoDB to MyISAM

"What? MySQL Fulltext Search is not working!"
Well, this is what I thought before. I used to have MyISAM tables when developing an application. I never thought about table types.

I then realized that I was using InnoDB table type where MySQL Fulltext search is not working.  So I had to alter the table from InnoDB to MyISAM.


Here's the code:

ALTER TABLE table_name ENGINE = MyISAM;

table_name
-It is the name of your table.

And that solved my problem! :)

In case that you want to get it back to InnoDB, here's the code:

ALTER TABLE table_name ENGINE = InnoDB;

If you have any inquiries/comments/questions/suggestions, just comment to this post. :)