PHP Classes
elePHPant
Icontem

PHP Auto Style Fixer: Beautify PHP source code fixing its style

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2019-05-29 (4 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 115 All time: 9,093 This week: 313Up
Version License PHP version Categories
phpas-php-auto-style 1.0GNU General Publi...5PHP 5, Utilities and Tools, Parsers
Description Author

This class can beautify PHP source code fixing its style.

It can take as parameter PHP source code either in the form of a string or the name of a file to be parsed using pure PHP code.

The class can fix several types of formatting aspects of the given PHP source like:

- Remove multiple consecutive line breaks
- Remove needless spaces in statments like for, while, if, etc.
- Remove indenting
- Reformat comments
- Etc..

  Performance   Level  
Name: Max Base <contact>
Classes: 3 packages by
Country: United States United States
Age: ???
All time rank: 3402405 in United States United States
Week rank: 747 Up79 in United States United States Up
Innovation award
Innovation award
Nominee: 1x

 

Details

PHP AS(Auto Style), PHP Beautifier

A tool for format and beautify the style of PHP code with my style.

Story

I developed this tool for myself, not for money, not for a special company.

Although it used in some software of a company in India.

We waste our time to format the code. So it will be a fantastic tool.

Anyway, I hope this tool can help you for format a PHP code easily and fast.

Main purpose

  • Remove extra space after "for", "while", "if" words...
  • Ident cleaning and auto tab for {} and statements...
  • Make clean the comment text
  • ...

Demo

Left: Output, Right: Input

ScreenShot

Using

<?php
include "PHPAS.php"
$AS=new AutoStyle();
///////////////////////////////////////
print $AS->loadFile("test.php") ."\n";
print $AS->loadString("<?php\nprint 'hi';\n") ."\n";

Functions

| Function Name | Goal | | ------------- | ------------- | | loadFile | Auto Style, format a file and display output... | | loadString | Auto Style, format a string code and display output... |

Input

<?php
/dfgdgdf gdfg/
for ($v = 7;$v <= 100 / 10;$v++) {
$b = $v;
$x = [];
for ($i = 1;$i <= $v;$i++) {
$x[] = $i;
}
for ($k = 3;$k <= ((floor($v - 1) / 2) + 1);$k++) {
$r = $k;
solve($x, $v, $b, $k, $r);
}
}

Output

<?php
/dfgdgdf gdfg/
for($v=7;$v<=100/10;$v++) {
	$b=$v;
	$x=[];
	for($i=1;$i<=$v;$i++) {
		$x[]=$i;
	}

	for($k=3;$k<=((floor($v-1)/2)+1);$k++) {
		$r=$k;
		solve($x,$v,$b,$k,$r);
	}

}

Input

<?php
/dfgdgdf gdfg/
for ($v = 7;$v <= 100 / 10;$v++) { $b = $v; $x = []; for ($i = 1;$i <= $v;$i++) {$x[] = $i;
}
for ($k = 3;$k <= ((floor($v - 1) / 2) + 1);$k++) { $r = $k;
solve($x, $v, $b, $k, $r); } }
$str="hello world!";

Output

<?php
/dfgdgdf gdfg/
for($v = 7;$v <= 100 / 10;$v++) {
	$b=$v;
	$x=[];
	for($i = 1;$i <= $v;$i++) {
		$x[]=$i;
	}

	for($k = 3;$k <= ((floor($v - 1) / 2) + 1);$k++) {
		$r=$k;
		solve($x, $v, $b, $k, $r);
	}
}

$str="hello world!";

Partnership and development

Please send issue or pull request if you found a bug or problem. Feel free to discuss or send pull...

License

PHPBeautifier is licensed under the GNU General Public License.

Screenshots  
  • screenshot.png
  Files folder image Files  
File Role Description
Files folder imagetests (1 file, 2 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file Example.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Plain text file PHPAS.php Class Class source
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  tests  
File Role Description
Files folder imageoutput (1 file)
Files folder imagephp (1 file)
  Accessible without login Plain text file Tests.php Example Example script

  Files folder image Files  /  tests  /  output  
File Role Description
  Accessible without login Plain text file 1.php Output Sample output

  Files folder image Files  /  tests  /  php  
File Role Description
  Accessible without login Plain text file 1.php Test Unit test script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:115
This week:0
All time:9,093
This week:313Up