There are lots of great resources out there for developing CakePHP apps in eclipse – but they are outdated and scattered.  I took the time tonight to setup my environment, so I figured I’d blog about it.  Below are the steps I took to get thinks as I like ’em. I run Ubuntu 10.10 64bit, but these directions should apply to any OS.  This requires you have CakePHP 1.3.X extracted someplace on your box.

  1. Install Eclipse 3.7 (indigo). If your just gonna do PHP development, get the classic version.
  2. Help > install new software > work with: all available sites > search for PDT. Install PDT.
  3. Optional: Install Subversive if you use SVN, or install Egit if you use git/github. Subversive is available in default indigo eclipse repo. For Egit, i’d recomend using the http://download.eclipse.org/egit/updates repo.
  4. Setup your PATH to use the cake console (optional, requires php5-cli to be installed).  This allows you to call ‘cake bake help’ for example, from your terminal.  Edit ~/.profile and add to the bottom of the file
    PATH="/path/to/cake/runtime/13/cake/console:$PATH"
  5. Setup eclipse so it can run ‘cake bake directly’ from the IDE.
    1. Open eclipse, go to your PHP explorer perspective.  From the menu choose Run > External Tools > External Tools Configurations
    2. Click Program, then new program (white page upper left). Give it a name like Cake bake.
    3. In the Location field put the full path to the cake console script.  I have 1 shared runtime on my box for all my CakePHP 1.3 based apps. Ex: /opt/cake/runtime/13/cake/console/cake. Note: If you typically run diff versions of cake or have the cake runtime directly in your project, you can insert variables in the location box (like workspace).
    4. Under Working Directory put ${project_loc}/app
    5. Under Arguments put ‘bake’
    6. Now click Apply then close.
    7. Test it out by clicking on a cake project (must have the structure of ‘project name’ with a subfolder called ‘app’), then clicking Run>External tools>Cake bake.  This will open a console that you can type in.
  6. Repeat Step 5 for other cake console things you would like to use from the IDE (like ‘cake console’ for example)
  7. Setup syntax highlighting for .ctp files:
    1. Window > Preferences > General > Appearance > content Types > Text > PHP Content type > Add.. , then put in *.ctp.
  8. Install Open Cake File eclipse plugin to enable fast switching between your MVC classes/files. This is not well known, but its a nifty plugin.

 

Thats it! If you know of any other cool things email me, and I’ll add em. Note: I left off code completion intentionally, as I big fan of the implementation of the solutions I’ve seen.

Advertisements