All Projects → adael → Sublimephpcsfixer

adael / Sublimephpcsfixer

Licence: mit
Run php-cs-fixer code formatter to format php code from your favorite text editor

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Sublimephpcsfixer

Squib
A Ruby DSL for prototyping card games.
Stars: ✭ 850 (+1249.21%)
Mutual labels:  sublime-text
Sublime Text Imfix
Fix Sublime Text 3 Input method problem (CJK words) under Ubuntu
Stars: ✭ 969 (+1438.1%)
Mutual labels:  sublime-text
Sublime Php Snippets
PHP snippets for Sublime Text.
Stars: ✭ 50 (-20.63%)
Mutual labels:  sublime-text
Sublime Bookmarks
Sublime Text essential plugins and resources
Stars: ✭ 878 (+1293.65%)
Mutual labels:  sublime-text
Vhdl Mode
A package for Sublime Text that aids coding in the VHDL language.
Stars: ✭ 31 (-50.79%)
Mutual labels:  sublime-text
Sublimall Server
Server behind Sublimall SublimeText plugin
Stars: ✭ 43 (-31.75%)
Mutual labels:  sublime-text
Sublimeallautocomplete
Extend Sublime autocompletion to find matches in all open files of the current window
Stars: ✭ 906 (+1338.1%)
Mutual labels:  sublime-text
Sublime Phpck
PHP completions for Sublime Text.
Stars: ✭ 58 (-7.94%)
Mutual labels:  sublime-text
Terminus
Bring a real terminal to Sublime Text
Stars: ✭ 967 (+1434.92%)
Mutual labels:  sublime-text
Sublime Text 2 User Settings
💾 2011–2013 — My user settings for Sublime Text 2
Stars: ✭ 45 (-28.57%)
Mutual labels:  sublime-text
Zenscript Highlighter
Sublime Text highlighting for ZenScript used in MineTweaker, CraftTweaker and ModTweaker
Stars: ✭ 15 (-76.19%)
Mutual labels:  sublime-text
Vscode Material Theme
Port of the sublime text Material theme for Visual Studio Code in light and dark.
Stars: ✭ 21 (-66.67%)
Mutual labels:  sublime-text
Lsp
Client implementation of the Language Server Protocol for Sublime Text
Stars: ✭ 1,018 (+1515.87%)
Mutual labels:  sublime-text
Dugong
Minimal State Store Manager for React Apps using RxJS
Stars: ✭ 10 (-84.13%)
Mutual labels:  sublime-text
Svg Snippets
🔰 A set of custom SVG snippets for Sublime Text 2/3
Stars: ✭ 50 (-20.63%)
Mutual labels:  sublime-text
Pawn Sublime Language
Pawn language settings for Sublime Text 3. Copied from C++ but with Pawn language and SA:MP specific modifications.
Stars: ✭ 26 (-58.73%)
Mutual labels:  sublime-text
Sublime Ava
Snippets for AVA
Stars: ✭ 41 (-34.92%)
Mutual labels:  sublime-text
Sublime Text Plugins For Frontend Web Development
📝 Collection of plugins for Frontend Web Development
Stars: ✭ 1,127 (+1688.89%)
Mutual labels:  sublime-text
Sublimelinter Contrib Xo
SublimeLinter plugin for XO
Stars: ✭ 53 (-15.87%)
Mutual labels:  sublime-text
Codeatlassublime
Code relationship graph visualization plugin of sublime editor
Stars: ✭ 44 (-30.16%)
Mutual labels:  sublime-text

Sublime PHP CS Fixer

This is a plugin for Sublime Text 3 to format PHP code through php-cs-fixer command on any view.

Features

  • It works inside a temporal view (ie: on an new, non-saved file)
  • Fast
  • Easy
  • Configurable through rules or a config file
  • Tested on Windows and Linux

Configuration

You have to install the actual php-cs-fixer (the actual tool made by sensiolabs, not this plugin)

You can install php-cs-fixer directly with composer by running:

composer global require friendsofphp/php-cs-fixer

Also you can create a config file as explained here https://github.com/FriendsOfPHP/PHP-CS-Fixer

for example in: $HOME/.phpcsfixer

<?php
return PhpCsFixer\Config::create()
->setRules([
    '@Symfony' => true,
    'array_syntax' => ['syntax' => 'short'],
]);

If you've created a config file, you have to configure its path in the plugin's settings.

In Menu -> Preferences -> Package Settings -> PHP CS Fixer -> Settings - user

{
    "config": "/path/to/.phpcsfixer"
}

When using multiple projects with different configurations, it's possible to configure the path relative to the Sublime project folder:

{
    "config": "${folder}/.php_cs.dist"
}

It's also possible to specify multiple config paths. In that case, the first readable file is used:

{
    "config": [
        "${file_path}/.php_cs",
        "${file_path}/.php_cs.dist",
        "${folder}/.php_cs",
        "${folder}/.php_cs.dist",
        "/path/to/.phpcsfixer"
    ]
}

See extract_variables in the Sublime API Reference for the supported replacement variables. The value of the ${folder} points the path of the first project in Sublime API. Here, it's beforehand replaced with the path of the project the target file belongs.

Please note that this plugin don't try to find the config file automatically. If you want to create a config file, you have to specify its path in the plugin settings.

Although you can configure the rules directly on your plugin settings, it's recommended to create the config file, as it's easier to configure every rule than using the 'rules' directive in the plugin settings.

Exclude files

Since all php files are passed directly to the php-cs-fixer executable, a configured PhpCsFixer\Finder gets ignored. In order to exclude files from php-cs-fixer, you can use the "exclude" setting:

{
    "exclude": [
        ".*[\\\\/]vendor[\\\\/].*", // vendor-path (used by Composer)
        ".*\\.phtml$" // files ending with ".phtml"
    ]
}

The exclude-filter uses python regular expressions. For more information see: https://docs.python.org/2/library/re.html

On Windows:

The plugin tries to find the executable in:

%APPDATA%\composer\vendor\bin\php-cs-fixer.bat

If it isn't working, you can locate your composer global packages path by running:

composer config -g home

On Linux:

After installing php-cs-fixer you have to specify the full path to the executable in the configuration page.

The plugin tries to find the executable in:

$HOME/.composer/vendor/bin/php-cs-fixer

However, if it isn't working, you can create a symbolic link to the php-cs-fixer executable

ln -s $HOME/.composer/vendor/bin/php-cs-fixer $HOME/bin/php-cs-fixer

Note

I've checked this on Linux and Windows, but I cannot check it on OSX. I'll thank you if someone tells me if it's working on OSX and give me some details on how to configure it.

Acknowledgements

I would like to thank to sensiolabs and contributors for their awesome package it works flawlessly. All the work here belongs to them.

Check them at:

I'd also learned some of the sublime package structure from:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].