Skip to content

Commit

Permalink
Update PHP Formatter (#333)
Browse files Browse the repository at this point in the history
* Try to use phpf as PHP formatter

* Try to use phpf as PHP formatter

* Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	codeformatter/phpformatter.py

* Update readme

* Update readme vol2
  • Loading branch information
akalongman authored Oct 30, 2017
1 parent 34b3848 commit a4a8cb5
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 18 deletions.
21 changes: 18 additions & 3 deletions CodeFormatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,28 @@ def run(self, edit, syntax=False):
if ('php_path' in opts and opts['php_path']):
php_path = opts['php_path']

php55_compat = False
if ('php55_compat' in opts and opts['php55_compat']):
php55_compat = opts['php55_compat']


cmd = []
cmd.append(str(php_path))
cmd.append(
'{}/CodeFormatter/codeformatter/lib/phpbeautifier/fmt.phar'.format(
sublime.packages_path()))

if php55_compat:
cmd.append(
'{}/CodeFormatter/codeformatter/lib/phpbeautifier/fmt.phar'.format(
sublime.packages_path()))
else:
cmd.append(
'{}/CodeFormatter/codeformatter/lib/phpbeautifier/phpf.phar'.format(
sublime.packages_path()))


cmd.append('--list')

#print(cmd)

stderr = ''
stdout = ''
try:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CodeFormatter is a Sublime Text 2/3 plugin that supports format (beautify) sourc

CodeFormatter has support for the following languages:

* PHP - By [phpfmt](https://github.com/subins2000/phpfmt)
* PHP - By [phpF](https://github.com/subins2000/phpF)
* JavaScript/JSON - By JSBeautifier
* HTML - By [Custom fork of BeautifulSoup](https://github.com/akalongman/python-beautifulsoup)
* CSS - By JSBeautifier
Expand Down Expand Up @@ -75,11 +75,11 @@ Make sure that you wrap all the configurations into a single root object.
## Formatter-specific notes
Following are notes specific to individual formatters that you should be aware of:
### PHP
PHP - Used phpfmt (https://github.com/subins2000/phpfmt) by Carlos Cirello, Shaked Klein Orbach and Subin Siby.
PHP - Used [phpF](https://github.com/subins2000/phpF) by [@subins2000](https://github.com/subins2000)

Getting and installing PHP - http://www.php.net/manual/en/install.general.php

You must install 5.6 or above (https://github.com/subins2000/phpfmt#requirements)
You must install 5.6 or above (https://github.com/subins2000/phpF#requirements)

On Linux/OSx after installation of package, you must set chmod +x to file fmt.phar in folder %PACKAGESDIR%/CodeFormatter/codeformatter/lib/phpbeautifier

Expand Down
Empty file modified codeformatter/lib/phpbeautifier/fmt.phar
100644 → 100755
Empty file.
Binary file added codeformatter/lib/phpbeautifier/phpf.phar
Binary file not shown.
14 changes: 2 additions & 12 deletions codeformatter/phpformatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,6 @@ def format(self, text):
if ('excludes' in self.opts and self.opts['excludes']):
excludes = self.opts['excludes']

formatter_path = os.path.join(
dirname(realpath(sublime.packages_path())),
'Packages',
'CodeFormatter',
'codeformatter',
'lib',
'phpbeautifier',
'fmt.phar'
)

cmd = []
cmd.append(str(php_path))

Expand All @@ -103,7 +93,7 @@ def format(self, text):
'codeformatter',
'lib',
'phpbeautifier',
'fmt.phar'
'phpf.phar'
)

cmd.append(formatter_path)
Expand Down Expand Up @@ -142,7 +132,7 @@ def format(self, text):
stderr = ''
stdout = ''

# print(cmd)
#print(cmd)

try:
if (self.formatter.platform == 'windows'):
Expand Down

0 comments on commit a4a8cb5

Please sign in to comment.