PHP Transpiler
This tool transpiles PHP code into optimized PHP code., (*1)
Implemented features:, (*2)
-
Inlines require and include statements., (*3)
-
Strips unnecessary whitespaces from the code., (*4)
-
Strips comments from code., (*5)
Example
Run against files test.php and include.php in the same directory given as:, (*6)
test.php, (*7)
<?php
require 'include.php';
class Foo {
public function msg() {
return (new Bar)->msg();
}
}
echo (new Foo)->msg();
include.php, (*8)
<?php
class Bar {
public function msg() {
return "Example Return Message\n";
}
}
Transpiles into a single test.php that contains:, (*9)
<?php class Bar{public function msg(){return 'Example Return Message
';}}class Foo{public function msg(){return (new Bar())->msg();}}echo (new Foo())->msg();
For more examples and details on this project see the project page., (*10)
Usage
Installation
To install globally via composer run, (*11)
composer global require brownbear/php-transpiler, (*12)
CLI
Either analyze a source file or directory via:, (*13)
php-transpiler analyze /src
or transpile a source directory into /out via:, (*14)
php-transpiler transpile /src /out
Library
Not documented yet :/, (*15)
, (*16)