Wednesday, February 23, 2011

CakePHP / Eclipse Project Integration

Creating projects in Eclipse that work with CakeBake is a multi-step process consisting of:
  1. Initiate a new PHP Project in Eclipse, e.g. php_project
    • enable JavaScript code checkbox
  2. Create your initial database so you can input the settings in step 3.
  3. In Terminal, run cake bake /path/to/php_project
    • add database settings if you have them
    • heed this info if you are using MAMP and the database does not resolve
  4. Use eGit or SVN in Eclipse to bring in any plugins you may need
  5. Configure Run > External Tools > External Tools Configurations to run further operation such as
    • cake bake model
    • cake bake view
    • cake bake controller
  6. You can also simply use Terminal to invoke interactive cake commands. Refresh Eclipse to see subsequent filesystem changes.
See this earlier integration post for more background.

3 comments:

Anonymous said...

Hi,
I've been working to get Cakephp working with the eclipse debugger also, but Eclipse is not prompting me for the path to the Cake php core code-- when I attempt to "step into" a class that's in the Cakephp core, I just get 'class not found', even though I've included that path in the 'build path'. Funny thing, I can highlight a given class name in the core, right click, and select 'goto code' and eclipse will open that module, but I cannot seem to get eclipse to 'step into' the core code when building the code. Any ideas?

jasonthewolf said...

Hi,

Have you added the cakephp source into Eclipse as a project? The chunk of library code you download for cakephp projects needs to be defined in your eclipse project view as a project. Let me know if you do that and it still doesn't work.

Anonymous said...

Hi,
Thanks so much for the tip regarding putting a copy of the cake core lib into the "baked" project code I created via external tools/cake.bat; I now have the debugger running, but I'm now getting build errors like this:

Debug Strict (PHP 5): C:\cake\cake\libs\object.php line 54 - Redefining already defined constructor for class Object
Debug Strict (PHP 5): C:\cake\cake\libs\inflector.php line 300 - Assigning the return value of new by reference is deprecated
Debug Strict (PHP 5): C:\cake\cake\libs\configure.php line 51 - Assigning the return value of new by reference is deprecated
.
.
.


Debug Strict (PHP 5): C:\cake\cake\libs\cake_log.php line 290 - Non-static method CakeLog::getInstance() should not be called statically, assuming $this from incompatible context

I'm using the 1.3 library for cake and php 5.2 for the zend debugger\compiler. It almost seems like I'm using the wrong php version, but all the links I've found suggest cake 1.3 supports 5.2, any observations?