Giter Club home page Giter Club logo

php-codebeautifier's Introduction

PHP-Codebeautifier

This is a plugin for Sublime Text 3 that gives the option to run the phpcbf

Prerequisite

You need the PHP Codesniffer more precise the code beautifier from them.

Install

Clone this repo into your Packages folder of Sublime Text. If phpcbf is in your path you don't need to do much setup. Otherwise create a user config for this plugin and set the path to your executable.

{
  "path": "/path/to/your/phpcbf"
}

Please note that the executable has to be in the string.

Usage

The usage is pretty straight forward just press CTRL+ALT+F or use the button in the Tools menu to execute it. For longer files give it a bit to run.

Configuration

Nearly all configuration options from phpcbf are bound to options in the settings file. Please refer to the documentiation for phpcbf to know what they do.

The three most important ones are

  1. path - Sets the path to the phpcbf executable
  2. level - Sets the code standard to follow. Default: psr-2
  3. patch - Sets whenether patch command should be used.

php-codebeautifier's People

Contributors

curtisgibby avatar ennosuke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

php-codebeautifier's Issues

can't find file to patch at input line 3

It looks like it can find problems, but it can't fix it by default. Here is the output from console:

Changing into directory /home/---/Projects/magento2/app/etc
Processing config.php [PHP => 816 tokens in 105 lines]... DONE in 16ms (1 fixable violations)
    => Fixing file: 1/1 violations remaining

    => Fixing file: 1/1 violations remaining [made 1 pass]... 

    => Fixing file: 0/1 violations remaining [made 2 passes]... �[32mDONE�[0m in 35ms
Array
(
    [0] => Ignoring potentially dangerous file name /home/---/Projects/magento2/app/etc/config.php
    [1] => can't find file to patch at input line 3
    [2] => Perhaps you used the wrong -p or --strip option?
    [3] => The text leading up to this was:
    [4] => --------------------------
    [5] => |--- /home/---/Projects/magento2/app/etc/config.php
    [6] => |+++ PHP_CodeSniffer
    [7] => --------------------------
    [8] => File to patch:
    [9] => Skip this patch? [y]
    [10] => Skipping patch.
    [11] => 1 out of 1 hunk ignored
)
Returned: 1
Time: 82ms; Memory: 5.5Mb

I know it's a phpcbf problem, it somehow can't create the patch file, so after adding this to to the user configuration file, it's working:

  "patch": 0

Syntaxes settings issue causing silent failure / return

Not an issue as such but took me some hair pulling to figure out, maybe someone else will

By default the supported syntaxes setting is an array containing only Packages/PHP/PHP.sublime-syntax. For some reason my ST3 uses Packages/PHP/PHP.tmLanguage instead, which was causing the run command to fail silently. Adding

"syntaxes": [
    "Packages/PHP/PHP.tmLanguage",
    "Packages/PHP/PHP.sublime-syntax"
]

to my user settings fixed the problem!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.