CakePHP auto-complete in NetBeans

Most annoying thing, while coding projects using CakePHP framework in NetBeans is lack of auto-complete feature for models and components in controllers. You can find some solutions that help avoid this problem like adding to each controller new variables and special phpDoc or adding @property to class phpDoc. In my opinion second option is easier, as it do not require to change code of class itself. So I could add manually this tags to each class. But as a programmer I’m lazy person. So I create this simple tool, which add necessary phpDoc properties to code of each controller, model, component and behavior.

How to use it?
First you have to install python on your machine. Then you have to download two files: caker.py and propertier.py and save them in one directory. Then open command line and type something like that:

caker.py -n ProjectName -d your/project/app -a

It will automatically add all properties to your code. Also it will add @package and @subpackage property (this is for generating better documentation using phpDoc).

If you prefer to add properties to single file you can type:

caker.py -n ProjectName -f controllers/user_controller.php -c

Other command line options:

  • -n ProjectName – name of project (used for generating @package)
  • -d directory – directory with cake project
  • -f fileName – single file to scan
  • -a – scan for controllers, models, components and behaviors
  • -c scan only controllers
  • -m scan only models
  • -o scan only components
  • -b scan only behaviors

Script in action:

Download current version of CakePHP AutoComplete

6 przemyśleń nt. „CakePHP auto-complete in NetBeans”

  1. Unfortunately the second method works only with netbeans 6.5 that is why I preferred the second one. Another reason is simply in the first method you can insert the variable anywhere in the class without the need to scroll to the top of the file to add a property 😉

    Another point is you can modify the CakePHP generators to add at least the required model, or associated models.

  2. For me both methods works fine in NetBeans 6.9 and 7.0.
    I prefer to keep such information close to file begin. It easier to maintenance later.

      1. Thank you very much for that.I was coming back to Aptana after many years and intllased 3.0 beta, but a lot of things are not functional/incorporated there yet but it looks very very promising, so put 2.0 on as well, and found PDT wasn’t working properly and was missing so many features for php, not even text drag and drop worked inside php editing (I checked all settings). Now I have got one of the best php editors working again thanks to your blog.Aptana have done such a great job, shame they missed a beat on php with version 2.0, put a lot of people off. Now I know what everyone was on about.They have got so much right, very professional, and 3.0 is looking like it is shaping up really well, its hard to imagine why php was ever dropped?I sincerely hope they don’t drop it again, but why is this information not more obvious on the Aptana site? Php is such an integral part of web editing for so many people. The person who only ever writes css js and html alone would be in a rare situation.

Dodaj komentarz

Twój adres email nie zostanie opublikowany. Pola, których wypełnienie jest wymagane, są oznaczone symbolem *