gk / phpstorm-configurator
配置PHPStorm项目(包括Symfony2插件)
dev-master
2018-11-14 10:22 UTC
Requires
- php: >=5.4.0
- symfony/console: ~2.6
- symfony/finder: ~2.6
This package is not auto-updated.
Last update: 2024-09-28 16:38:53 UTC
README
一个帮助配置phpstorm项目的工具(添加排除文件夹、启用symfony2插件等)
安装(全局使用composer)
$ composer global require gk/phpstorm-configurator:dev-master
确保您的 PATH
包含 ~/.composer/vendor/bin
export PATH="$PATH:$HOME/.composer/vendor/bin"
CLI使用
phpstorm-configurator configure
将当前工作目录配置为PHPStorm项目。(简单用法没有用,您最好使用 pstorm .
)
排除文件夹
phpstorm-configurator configure --exclude app/cache -exclude app/logs
或者,使用简写选项
phpstorm-configurator configure -x app/cache -x app/logs
Symfony2插件
phpstorm-configurator configure --plugin symfony2
或者,使用简写选项
phpstorm-configurator configure -p symfony2
将 app/cache
和 app/logs
标记为排除,并启用 Symfony2插件
代码使用
如果您想调整项目的配置
#!/usr/bin/env php <?php require_once $_SERVER['HOME'] . "/.composer/vendor/autoload.php"; $projectDir = getcwd(); $configurator = new \Gk\PHPStormConfigurator\ProjectConfigurator($projectDir); /** * Exclude some folders */ $imlPlugin = $configurator->getPlugin('iml'); $imlPlugin ->addExcludeFolder('app/cache') ->addExcludeFolder('app/logs') ; /** * Configure the Symfony2 plugin (http://symfony2-plugin.espend.de/). * This also excludes the app/cache and app/logs directories */ $symfony2Plugin = $configurator->getPlugin('symfony2'); $symfony2Plugin ->addOption("directoryToApp", "app") ->addOption("pathToUrlGenerator", "app/cache/dev/adminDevUrlGenerator.php") ->addOption("pathToTranslation", "app/cache/dev/translations") ->addContainerFile("app/cache/dev/adminDevDebugProjectContainer.xml") ; /** * Add some files/directories to the default favorite list. * The directories must be traversed recursively, for each child PHPStorm requires an entry in workspace.xml * Adding directories with a large number of children can slow down your script. */ $workspacePlugin = $configurator->getPlugin('workspace'); $workspacePlugin ->addToFavorites($projectDir . '/dir1') ->addToFavorites($projectDir . '/file2') ; $configurator->writeConfig();