geecu / phpstorm-configurator

A tool to help configuring phpstorm projects (add excluded folders, enable symfony2 plugin, etc.)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

phpstorm-configurator

A tool to help configuring phpstorm projects (add excluded folders, enable symfony2 plugin, etc.)

Installation (globally, using composer)

$ composer global require gk/phpstorm-configurator:dev-master

make sure you have ~/.composer/vendor/bin in your PATH

export PATH="$PATH:$HOME/.composer/vendor/bin"

CLI Usage

phpstorm-configurator configure

Configures the currently working directory as a PHPStorm project. (The simple usage is useless, you'd better use pstorm .)

Exclude folders

phpstorm-configurator configure --exclude app/cache -exclude app/logs

or, using the shorthand options

phpstorm-configurator configure -x app/cache -x app/logs

Symfony2 plugin

phpstorm-configurator configure --plugin symfony2

or, using the shorthand options

phpstorm-configurator configure -p symfony2

This marks app/cache and app/logs as excluded and enables the Symfony2 plugin

Code usage

If you want to finetune the configuration of the project:

#!/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();

About

A tool to help configuring phpstorm projects (add excluded folders, enable symfony2 plugin, etc.)

License:MIT License


Languages

Language:PHP 100.0%