Better config for CakePHP?

My PHP work is almost exclusively in CakePHP and so I would like to get things working with Cake in PHPStorm as smoothly as possible. :)

I'm trying to get all the auto-complete magic to work find. As you may or may not know, the Model objects are implicitly assigned in the Controller.

This post talks a little bit about it:
http://devnet.jetbrains.net/message/5264817

And so I have:

<?php

/*
* @property Carrier Carrier Carrier controller
* @property Region Region Region controller
*/


class CarriersController extends AppController {

    private $Carrier;
....

In my code.  And so $this->Carrier completes, but PHPStorm doesn't know that Carrier is a Carrier model, so it doesn't auto-complete any of the model methods (like find, save, etc).

Any one have any ideas?

5 comments

While I know nothing about CakePHP archiecture I do knew how IDE works and help to get it working.

@property annotation should provide both field name and appropriate class.
1) Is there a class named 'Carrier' / 'Region' in your project?
2) I so, does it have properties/methods you expect to complete explicitly declared, either directly or in superclass?
3) If it uses some __magic than you'll need to provide @property/@method annotations. Does it help?

0

The problem isn't that that PHPStorm won't complete the property, it's that is doesn't know that the IDE doesn't know that $this->Carrier is really a Carrier model.

If I control-click on the object, it says "Can't find declaration to go to" (see attached screenshot).  For me, I would like autocomplete in the methods inside the model objects themselves.



Attachment(s):
phpstorm_cake_error.png
0

BTW, just reviewed your original post example:
<?php


/*
* @property Carrier Carrier Carrier controller
* @property Region Region Region controller
*/




class CarriersController extends AppController {



    private $Carrier;

you should have either @property annotation or actual declaration with @var type annotatoion:

/** @var Carrier */
private $Carrier;

0

Thanks, Alexey  for explaining it to me. That worked great!

0

I was curious if you would be willing to share what you ultimately did to get this working.

0

Please sign in to leave a comment.