Download the PHP package trovit/php-code-formatter-bundle without Composer
On this page you can find all versions of the php package trovit/php-code-formatter-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download trovit/php-code-formatter-bundle
More information about trovit/php-code-formatter-bundle
Files in trovit/php-code-formatter-bundle
Package php-code-formatter-bundle
Short Description Provides a basic system to organize and execute php code formatters
License MIT
Informations about the package php-code-formatter-bundle
Php Code Formatter Bundle
Symfony bundle which provides a basic system to organize and execute php code formatters.
Installation
Step 1: Require bundle using composer
Step 2: Enable the bundle
Step 3: Configure the bundle
There are only 2 parameters available at the moment:
-
temporary_path (string): temporary path where the temporary files should be created. This is necessary for those formatter libraries that only works with filesystem.
- formatter_services (string[]): each string represents the reference name of a formatter service
Example:
Step 4 (optional): Create your own Formatter
When you need to format your code and the formatters provided by this bundle doesn't satisfy your needs (different code language, formats, etc...) there is the possibility to create a new Formatter class by implementing the Formatter interface (Trovit\PhpCodeFormatter\Formatters\Formatter) and implement its method formatCode
After that, you have to register the formatter as a service and add the service reference name in the config (check step 3).
Usage
Get the manager service wherever you want to call the method execute with the bad formatted code as a parameter. It will return the formatted code.
Example with the PhpCsFormatter:
List of available formatters
- PhpCsFormatter (with default configuration): Wrapper of PHP CS Fixer by Fabien Potencier & Dariusz Rumiński
Feel free to add more formatters and contribute by PR!