Associating CakePHP .ctp Files in Aptana, Eclipse


Viewing CakePHP’s .ctp files in Aptana Studio has been quite annoying due to the lack of syntax highlighting. I have grown use to it until earlier today when I was converting a .php file into a .ctp. I knew there had to be a way to associate .ctp files with .php files in Aptana/Eclipse. I did a bit of searching and found the solution.

  1. Go to Window/Preferences/General
  2. Select Content Types
  3. In the right pane, select the Text Navigation tree
  4. Select PHP Content Type
  5. Click the Add button
  6. Enter *.ctp and click Ok

If you have a .ctp file open, you will have to close and re-open it to view the changes. Much better.

Checkout My New Site - T-shirts For Geeks

Setting up Aptana Studio to work with CakePHP


I’ve been using Aptana Studio (based on Eclipse) on my Mac for over a year. It has become my default development IDE. When I first installed CakePHP, I could not understand why I was receiving errors when viewing test files in the browser. I eventually figured out that the problem was the location of my Cake files.

The important thing to remember is that the CakePHP files must exist on the root level of your web server – it can’t be located in a sub directory. Most of my projects are located under my ‘Aptana Studio’ workspace (a sub directory located on the root of my web server). So I assumed that I could do the same with CakePHP – although the documentation specifically says to place the files directly under root (at times it helps to follow the directions).

The problem is that I often work on multiple projects at a time so if I placed the Cake files outside my primary workspace, I would have to continually switch in and out of workspaces. But I found out that Aptana Studio (or eclipse) can be easily set up to work with CakePHP.

  1. Create a folder under root. Name it cake (can be named anything).
  2. Download CakePHP from here and unzip. Place the unzipped files in the cake folder.
  3. Start a new project in Aptana Studio (File->New->Project).
  4. Select PHP Project as a type and click next.
  5. On the next screen, name your project then uncheck Use Default Location
  6. Browse to the cake folder that you created (and select).
  7. Select this folder and then click finish.

That’s it. You should now be able to see your CakePHP files in your current workspace.

Checkout My New Site - T-shirts For Geeks