GithubHelp home page GithubHelp logo

phpbeautifier's Introduction

PHP code formatter for Sublime Text editor with Pear php_beautifier

About

This is a Sublime Text 2 plugin allowing you to format your PHP code. It uses php beautifier.

Installation

Install php-pear and php-cli with your package manager :

  • php-pear & php5-cli with Debian
  • php-pear & php with Archlinux

Install php beautifier from pear channel : sudo pear install --alldeps channel://pear.php.net/php_beautifier-0.1.15

Clone or download the files and copy them to your Packages folder. You can access it via Preferences -> Browse Packages in sublime text.

Usage

ctrl + shift + P and type Format: PHP, or you can use the ctrl + alt + f keybinding.

Customize

You can define some options in the script php_beautifier.py. Default options are : PHP_OPTIONS = "-s4 -l 'ArrayNested()' " (indent with 4 spaces and nested arrays).

phpbeautifier's People

Contributors

barbuk avatar fichtefoll avatar jbrooksuk avatar saivert avatar

Stargazers

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

Watchers

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

phpbeautifier's Issues

sh: php_beautifier: command not found

I followed the installation instructions and made sure php_beautifier is in my path (it's at /usr/local/bin). I'm running Mac OSX 10.7. The result when I run the format command is

sh: php_beautifier: command not found

I tried editing the python file and specifying the full path to the php_beautifier executable, and that does get rid of the error message, but the source code just goes blank instead.

AttributeError: 'PhpBeautifierCommand' object has no attribute 'status'

Traceback (most recent call last):
File "./sublime_plugin.py", line 362, in run_
return self.run(edit)
File "./php_beautifier.py", line 20, in run
AttributeError: 'PhpBeautifierCommand' object has no attribute 'status'

Running in Ubuntu 12.10.4, following installation as suggested

Not working...

Just installed it in Ubuntu 12.04. Doesn't do anything at all!

TypeError: 'NoneType' object is unsubscriptable

Hi,

I just tried this plugin and couldn't get it to go..

Sublime Version 2.0.1,
Build 2217

File "./sublime_plugin.py", line 362, in run_
File "./php_beautifier.py", line 8, in run
TypeError: 'NoneType' object is unsubscriptable

Cant seem to change filters

There seems to be an issue with the filters line. If I try to add or remove stuff, it doesnt work on the plugin anymore?

IE: remove the ArrayNested() from the php_beautifier.py file. Run the format on a file, still formats the file the same way, as if ArrayNested() was still a filter.

Any help?

.

This plugin connects to an external webserver and probably saves your code. BE WARNED.

settings json file parsing error due to extra ,

---------------------------
Sublime Text 2
---------------------------
Error trying to parse file: Trailing comma before closing bracket in C:\Users\Amit.Shah\AppData\Roaming\Sublime Text 2\Packages\PHP Codebeautifier\Main.sublime-menu:8:13
---------------------------
OK   
---------------------------

Resolved by removing , from the end on line 7
"command": "php_cbf"

The same errors are present in couple of other setting files.

PHP Strict Standards: Non-static method Console_Getopt::readPHPArgv() should not be called statically in /usr/bin/php_beautifier on line 70

PHP Strict Standards: Non-static method Console_Getopt::readPHPArgv() should not be called statically in /usr/bin/php_beautifier on line 70
PHP Strict Standards: Non-static method Console_Getopt::getopt() should not be called statically in /usr/bin/php_beautifier on line 84
PHP Strict Standards: Non-static method Console_Getopt::doGetopt() should not be called statically in /usr/share/php/Console/Getopt.php on line 92
PHP Strict Standards: Non-static method PEAR::isError() should not be called statically in /usr/share/php/Console/Getopt.php on line 109
PHP Strict Standards: Non-static method Console_Getopt::_parseShortOption() should not be called statically in /usr/share/php/Console/Getopt.php on line 166
PHP Strict Standards: Non-static method PEAR::isError() should not be called statically in /usr/share/php/Console/Getopt.php on line 167
PHP Strict Standards: Non-static method Console_Getopt::_parseShortOption() should not be called statically in /usr/share/php/Console/Getopt.php on line 166
PHP Strict Standards: Non-static method Console_Getopt::_isShortOpt() should not be called statically in /usr/share/php/Console/Getopt.php on line 220
PHP Strict Standards: Non-static method Console_Getopt::_isLongOpt() should not be called statically in /usr/share/php/Console/Getopt.php on line 221
PHP Strict Standards: Non-static method PEAR::isError() should not be called statically in /usr/share/php/Console/Getopt.php on line 167
PHP Strict Standards: Non-static method Console_Getopt::_parseShortOption() should not be called statically in /usr/share/php/Console/Getopt.php on line 166
PHP Strict Standards: Non-static method Console_Getopt::_isShortOpt() should not be called statically in /usr/share/php/Console/Getopt.php on line 220
PHP Strict Standards: Non-static method Console_Getopt::_isLongOpt() should not be called statically in /usr/share/php/Console/Getopt.php on line 221
PHP Strict Standards: Non-static method PEAR::isError() should not be called statically in /usr/share/php/Console/Getopt.php on line 167
PHP Strict Standards: Non-static method Console_Getopt::_parseShortOption() should not be called statically in /usr/share/php/Console/Getopt.php on line 166
PHP Strict Standards: Non-static method Console_Getopt::_isShortOpt() should not be called statically in /usr/share/php/Console/Getopt.php on line 220
PHP Strict Standards: Non-static method Console_Getopt::_isLongOpt() should not be called statically in /usr/share/php/Console/Getopt.php on line 221
PHP Strict Standards: Non-static method PEAR::isError() should not be called statically in /usr/share/php/Console/Getopt.php on line 167
PHP Strict Standards: Non-static method PEAR::isError() should not be called statically in /usr/bin/php_beautifier on line 85
PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/php/PEAR/Config.php on line 650
PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/php/PEAR/Config.php on line 697
PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/php/PEAR/Config.php on line 757
PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/php/PEAR/Config.php on line 786
PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/php/PEAR/Config.php on line 914
PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/php/PEAR/Config.php on line 1577
PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/php/PEAR/Config.php on line 1607
PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/php/PEAR/Config.php on line 2038
PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/php/PEAR/Config.php on line 2091
PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/php/PEAR/Registry.php on line 322
PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/php/PEAR/Registry.php on line 1450
PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/php/PEAR/Registry.php on line 1458
PHP Strict Standards: Non-static method System::tmpdir() should not be called statically, assuming $this from incompatible context in /usr/share/php/PEAR/Config.php on line 158
PHP Strict Standards: Non-static method System::tmpdir() should not be called statically, assuming $this from incompatible context in /usr/share/php/PEAR/Config.php on line 167
PHP Strict Standards: Non-static method System::tmpdir() should not be called statically, assuming $this from incompatible context in /usr/share/php/PEAR/Config.php on line 176
PHP Strict Standards: Non-static method System::which() should not be called statically, assuming $this from incompatible context in /usr/share/php/PEAR/Config.php on line 228

PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/lib/php/pear/PEAR/Config.php on line 650

OSX 10.7
PHP 5.3.6
php_beautifier-0.1.15
Sublime Text 2 Build 2165
PhpBeautifier v2012.01.20.03.15.20

PHP Deprecated:  Assigning the return value of new by reference is deprecated in /usr/lib/php/pear/PEAR/Config.php on line 650
PHP Stack trace:
PHP   1. {main}() /usr/bin/php_beautifier:0
PHP   2. PHP_Beautifier_Batch->addFilter() /usr/bin/php_beautifier:207
PHP   3. PHP_Beautifier_Decorator->__call() /usr/bin/php_beautifier:207
PHP   4. call_user_func_array() /usr/lib/php/pear/PHP/Beautifier/Decorator.php:47
PHP   5. PHP_Beautifier->addFilter() /usr/lib/php/pear/PHP/Beautifier/Decorator.php:47
PHP   6. PHP_Beautifier->addFilterFile() /usr/lib/php/pear/PHP/Beautifier.php:448
PHP   7. include_once() /usr/lib/php/pear/PHP/Beautifier.php:511
...

UnicodeEncodeError: 'ascii' codec can't encode character

The file is in UTF-8, Unix.
When execute ctrl+alt+f the console shows:

Traceback (most recent call last):
  File "./sublime_plugin.py", line 351, in run_
  File "./php_beautifier.py", line 16, in run
  File ".\subprocess.py", line 701, in communicate
  File ".\subprocess.py", line 1210, in _communicate
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 126: ordinal not in range(128)

If file's content has no accents in all works great.
An idea?

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.