如果到facebook上关注一下yii framework的群组,会发现有人在介绍yiicookbook.org,里面是一本关于1.1的书。
然后去yii framework官方上搜索一下phpstorm,会发现同一个人在说自己用phpstorm,问phpstorm有没有什么支持。结果官网说暂时好象不支持。。。
然后再搜索了一下,发现在yii的官网有一个简单的例子在说如何让项目支持yii framework。看了一下,发现,大多数都用过,只有第一点,说是把yiilite.php过滤掉。这个其实很重要了,否则有些变量就会出现提示两次。
OK,来看官网的wiki吧:http://www.yiiframework.com/wiki/92/configuring-phpstorm-ide-for-yii
Code completion
- Exclude yiilite.php from index:
- File → Settings → IDE Settings → File Types.
- yiilite.php to Ignore files and folders.
- Exclude not used directories, specify resources.
- File → Settings → Project settings → Directories.
- Mark framework/cli/views, protected/runtime and assets as excluded.
- Mark website root as resource root.
- Specify path to your PHP.
- File → Settings → Project settings → PHP → PHP Home.
- If your project uses common Yii framework folder you need to include it.
- File → Settings → Project settings → PHP → PHP Home → Add.
- Specify a path to framework directory.
- If you are writing unit tests you can include PHPUnit to get code completion:
- File → Settings → Project settings → PHP → PHP Home → Add.
- Specify a path to PHPUnit.
- Complete code: Ctrl+Space.
- Show method arguments: Ctrl+Q.
Testing
You should install PHPUnit to run unit tests.
- PHPUnit.
- Follow official PHPUnit installation guide.
- In your IDE: Run → Edit configurations.
- Press "+".
- 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.
- To run tests use SHIFT+F10.