0

Has anyone found a way to achieve code completion in CakePHP, using Eclipse?

Furthermore, is there a way to debug step-by-step, through Models, Controllers and Views in a CakePHP environment?

I have come across a couple of writeups that mostly mentioned setting the project path etc... But I did not help achieve code completion.

dda
  • 6,030
  • 2
  • 25
  • 34
Ajay K
  • 354
  • 1
  • 4
  • 14

1 Answers1

2

Don't know about eclipse, but PhpStorm works fine with CakePHP (and is a great IDE).

You may have to exclude some of the test-cases (because they contain duplicate class definitions) and add PhpDoc here and there to assist code-completion. This probably applies to most other IDE's as well;

For Model-method autocompletion, I add this to the PhpDoc of my controllers

/**
 * @property MyModelName   $MyModelName
 */

Inside your views, layouts and elements (.ctp), put a PhpDoc block at the start, containing at least this:

/**
 * @var View   $this
 * @var string $title_for_layout
 *
 * other viewVars can be put here
 */

This way, your IDE will 'understand' that a .ctp file should be considered a 'View' object

For debugging, you may consider XDebug, don't know how good it can be integrated in Eclipse, but here's some examples in PhpStorm, how to set break-points etc.;

http://blog.jetbrains.com/webide/2011/02/zero-configuration-debugging-with-xdebug-and-phpstorm-2-0/ PHPStorm + XDebug Setup Walkthrough

Community
  • 1
  • 1
thaJeztah
  • 27,738
  • 9
  • 73
  • 92
  • MyModelName is replaced by the modelName, like User $User, right? – anvd Apr 04 '13 at 00:50
  • Yup, that's the Idea. `MyModelName` is the *classname* and `$MyModelName` the name of the property. **update** I noticed I had put the example for the *controller* incorrect; `@var` should be `@property` to define Class-properties. I modified my answer. – thaJeztah Apr 04 '13 at 06:48
  • Update : Moved to NetBeans. Added the CakePHP plugin. It has decent support (mostly code completion) for PHP and Cake. – Ajay K Apr 05 '13 at 10:46
  • Did you happen to get PHPStorm + CakePHP to work with debugging? I had to switch to Netbeans as I simply could not get it working properly. It could only break at the first line in the index file. I think it's due to the fact that it's a CakePHP project. – Simon Langhoff May 21 '14 at 22:17