/phpfmt

Primary LanguagePython

phpfmt support for Sublime Text 3 for Windows

This project follows a Code of Conduct.

Report issues.

Installation

Requirements

  • You must have a running copy of PHP on the machine you are running Sublime Text

Plugin runs with PHP 7.0 or newer installed in the machine running the plugin.

Configuration (Windows)

  • Edit configuration file (%AppData%\Sublime Text\Packages\phpfmt\phpfmt.sublime-settings)
  • For field "php_bin" enter the path to the php.exe Example: "php_bin":"c:/PHP/php.exe"

Settings

Prefer using the toggle options at command palette. However you might find yourself in need to setup where PHP is running, use this option below for the configuration file.

{
"php_bin":"c:/PHP/php.exe"
}

What does it do?

Before After
<?php
for($i = 0; $i < 10; $i++)
{
if($i%2==0)
echo "Flipflop";
}
<?php
for ($i = 0; $i < 10; $i++) {
	if ($i%2 == 0) {
		echo "Flipflop";
	}
}
<?php
$a = 10;
$otherVar = 20;
$third = 30;
<?php
$a        = 10;
$otherVar = 20;
$third    = 30;
This can be enabled with the option "enable_auto_align"
<?php
namespace NS\Something;
use \OtherNS\C;
use \OtherNS\B;
use \OtherNS\A;
use \OtherNS\D;

$a = new A(); $b = new C(); $d = new D();

<?php
namespace NS\Something;

use \OtherNS\A; use \OtherNS\C; use \OtherNS\D;

$a = new A(); $b = new C(); $d = new D();

note how it sorts the use clauses, and removes unused ones

Acknowledgements