yiilite.php from index:
File → Settings → IDE Settings → File Types.yiilite.php to Ignore files and folders.File → Settings → Project settings → Directories.framework/cli/views, protected/runtime and assets as excluded.resource root.File → Settings → Project settings → PHP → PHP Home.File → Settings → Project settings → PHP → PHP Home → Add.framework directory.File → Settings → Project settings → PHP → PHP Home → Add.Ctrl+Space.Ctrl+Q.In order to be able to get from render or renderPartial to the view, from widget to widget class, from relations to model classes you need to install additional plugin called YiiStorm.
You should install PHPUnit to run unit tests.
Run → Edit configurations.Name: anything.Test: depending on what do you want to test select an appropriate option. Specify path.Use XML configuration file: specifying path to phpunit.xml. Often it's path_to_your_webroot/protected/tests/phpunit.xml.SHIFT+F10.
Total 13 comments
Hi,
Is there a way to let the IDE know automatically the methods provided by behaviors attached to a model, as defined in its 'behaviors()' method? I emphasize 'automatically' as I know I can use a doc block above the model class, with a comment such as:
I want to avoid needing to manually write (and maintain) all those methods.
If there's no such solution, does anyone know about an open bug/feature-request on this?
Thanks
I'm no expert so does anyone know how to take advantage of it (besides what's described here)? Thanks in advance.
Hello, for a bigger project I needed the @var in all my models from database so I wrote a yii command to do this automatically. I've posted it here. Please try it carefully it worked with my codebase quite well but could go rampage when the code is strangely formatted/structured.
Hey all, If you want to have auto complete for the component's attributes and methods, Just use with that code:
In your main index.php, just include the YiiBase.php (not yii.php).
To:
And just add this code after $yii include line:
and now you can use with Yii::app()->user->id and all what you need :)
Have fun :)
If there is a symbolic link in one of your libraries, you will need to tell PHPStorm about the symbolic link through a path mapping. For example, XAMPP uses the following symbolic links:
To include the Yii framework in your project,
1) Go to Preferences>Project Settings>PHP Home and add a PHP include path "/Applications/XAMPP/htdocs/yii".
2) Go to Preferences>Project Settings>PHP>Server and enable path mapping for the server. Create the following path mapping: "/Applications/XAMPP/htdocs/yii" -> "/Applications/XAMPP/xamppfiles/htdocs/yii".
Nice guide! I finally have all the autocompletion working properly.
I attempted following boaz's guide for the debugging connection but must have gone wrong somewhere. If found a guide by the makers which requires less configuration and worked immediately (after setting the xdebug.remote_enable = 1);
Link to guide
edit: now both debugging variants work. Happy days!
How could I make php storm aware of the yii components loaded? So that lines like this:
have auto complete for the component's attributes and methods? :)
I have seen it happen in netbeans..
@codescope: also see comment http://www.yiiframework.com/wiki/92/configuring-phpstorm-ide-for-yii/#c5646 for info on using @var tag to make the IDE know the variable type. This is still highly needed or used in Yii code.
I had some issues with method showing up as not existing in current class although they were in parent class . I went to phpstorm forums and they linked back here with some additional checks to perform. I did as mentioned in this wiki and also added yii framework in settings->project settings->directories instead of adding it in external libraries and it is perfectly configured now.
I think its good to have a section of "debugging" in this wiki article. I've sketched below a draft for its content. Its a big topic which probably deserves a separate wiki. Nevertheless, here it is:
Debugging on localhost
Many developers have a working web server on the same machine in which they develop. The following instructions are suitable for a simple use case where a developer run his web app on the same machine (with URL like mysite.local) and where the IDE edits the code in the doc root directly. This article is not intended to be a complete debugging PHP web app tutorial but just to hint the reader in the places to edit with basic values to use as configuring the IDE and the environment for debugging might require more work and configuration. The Internet have lots of useful tutorials these days for PHP debugging (for example (a bit old but still useful): http://www.rymland.org/en/blogs/boaz/3_mar_08/using-pdt-xdebug-debugging-drupal-projects).
Prerequisites
This assumes that you'll use the popular xDebug PHP extension for the server side debugger component (the client side is PHP Storm itself). Make sure to install it in your PHP environment where you'll do the debugging (localhost). Please refer to xDebug documentation for information about this. Don't forget to edit xdebug.ini in your PHP's configuration to have "xdebug.remote_enable=1"
Configuring web server for project
First, we're gonna need to tell the IDE about the web server it needs to talk to: File -> Settings -> Project settings -> PHP -> Servers. Click (+) -> Name: give a name (example: mysite localhost); Host: hostname used to access the web app from the browser (example: mysite.local is a commonly used convention); port: probably leave on 80; Debugger: xdebug Click Apply, then Ok.
Menu bar: Run -> Edit configurations. We're gonna create a new configuration: Click (+) -> PHP web application: Name: your preferred name (example: mysite localhost); Server: choose the server created in above steps in this drop down selector; Start URL: leave on "/"; Browser: choose your browser (you might need to configure this in advance in Settings -> IDE Settings -> Web Browsers); Other parameters - to your liking. I leave the other checkboxes unchecked. Click Apply, then Ok.
Starting a debug session
From the tool bar, click on dropdown which now shows the name of the debug configuration you've created in previous step. Then click on the "Debug " button which is typically the second button to the right of the configurations drop down you've just selected. A debug session will be opened:
In PhpStorm for Mac OS X, there are some differences:
yiilite.phpfrom index:PhpStorm → Preferences → [IDE Settings] File Types.yiilite.phptoIgnore files and foldersfield.PhpStorm → Preferences → [Project Settings] Directories.framework/cli/views,protected/runtimeandassetsasexcluded.resource root./Applications/MAMP/bin/php/php5.3.6/binPhpStorm → Preferences → [Project Settings] PHP.PhpStorm → Preferences → [Project Settings] PHP → Add.frameworkdirectory.PhpStorm → Preferences → [Project Settings] PHP → Add.There is no "Project settings → PHP → PHP Home" now, you can add yii folder as include path in "Project settings → PHP".
It's not possible to exclude the cli/views folder when yii is "connected" as a folder in the include path. All you can do to avoid "multiple declarations" problems with SiteController and Controller classes is to mark files [framework]/cli/views/webapp/protected/components/Controller.php and .../controllers/SiteController.php as plain text (right click on each file and select "Mark as Plain Text" in the context menu).
If you would like to be able to use code completion in your views you can add the comment:
at the top, you can also add any variables assigned via the CController::render() function.
Leave a comment
Please login to leave your comment.