Using CakePHP with your IDE

Friday, 5 June 2009 03:26 , In , ,

CakePHP 1.2.x uses .ctp files by default which means you will probably lose syntax highlighting in your chosen editor. CakePHP 1.1.x uses .thtml files.

In this tutorial we'll show you how to set up syntax highlighting for .thtml and .ctp files.

CakePHP and Eclipse


To set up your version of Eclipse to read either file type, follow these steps:

  • Go to Window > Preferences > General > Content types
  • In the content types window navigate the tree to text > PHP content type
  • Click add
  • Enter *.ctp or *.thtml depending on what version of CakePHP you use. It might be best to add both - just in case.
  • Now navigate to Editors > File Associations
  • Enter *.ctp or *.thtml depending on what version of CakePHP you use.
  • Under "Associated Editors:", select the PHP Editor and click Default.


CakePHP and Dreamweaver


  • Go to your Dreamweaver installation folder (let's assume this is C:\Program Files\Adobe\Adobe Dreamweaver CS3)
  • Open the configuration folder
  • Edit extensions.txt and modify the first line so THTML and CTP are present (comma seperated. It should look something like this: ,MASTER,THTML,CTP:All Documents
  • Edit the PHP files line in the same way. It should look like this: PHP,PHP3,PHP4,PHP5,TPL,THTML,CTP:PHP Files
  • Now browse to the DocumentTypes folder and open MMDocumentTypes.xml.
  • Do a ctrl-f search for "winfileextension" and modify the line to look like this: winfileextension="php,php3,php4,php5,thtml,ctp"
  • Do the same for "macfileextension": macfileextension="php,php3,php4,php5,thtml,ctp"
  • Now go to your "Document and Settings" folder (found under your username e.g. "C:\Documents and Settings\Your User Name\Application Data\Adobe\Dreamweaver 9\Configuration"
  • Edit "Extensions.txt" and add the same lines you added to the other extensions file.

Using CakePHP with Aptana


  • From the Window menu, select Preferences..., and then choose General > Editors > File Associations.
  • Add the appropriate file type.
  • Next to the File Types list, click the Add button.
  • In the New File Type pop-up window, type the appropriate file extension (e.g. ".ctp" or ".thtml").
  • Click OK to add the New File Type to the List.
  • Associate the new file type with Aptana.
  • On the File Types list, select the file type that you just added.
  • Next to the Editor Associations list, click the Add button.
  • On the Editor Selection pop-up window, select the editor that you want to associate with your file type.
  • Click OK to add the editor.
  • The new is now associated with the specified file type.
  • Click OK to apply your changes and close the Preferences window.

CakePHP with gEdit or other Linux editors


Edit the /etc/mime.types file to point .ctp or .thtml files to the relevant editor you are using.

6 comments:

clod said...

Look at the free PHP IDE Codelobster PHP Edition with CakePHP plug-in.

7 June 2010 at 04:03
kk said...

Eclipse users: don't forget to restart!

15 July 2010 at 06:48
Unknown said...

Very good article..help me alot

29 July 2010 at 00:40
Unknown said...

Thanks for another great post. It will surely improve our coding practice. Keep sharing similar stuff.
php programming India

20 October 2010 at 23:35

Post a Comment