machy8 / google-closure-compiler
PHP client for the Google Closure Compiler API in one file.
Installs: 1 896
Dependents: 2
Suggesters: 2
Security: 0
Stars: 5
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: >=7.0
Requires (Dev)
- nette/tester: ^1.7
- tracy/tracy: ^2.4
This package is auto-updated.
Last update: 2024-12-11 14:47:50 UTC
README
⚡ PHP client for the Google Closure Compiler API in one file.
Requirements
- PHP 7.0+
- If you use Nette Framework - v2.3+
Installation
1 - Download the Google Closure Compiler client using composer:
composer require machy8/google-closure-compiler
2 - Usage:
Typical:
$compiler = new GoogleClosureCompiler\Compiler; $response = $compiler->setJsCode($code)->compile(); if ($response && $response->isWithoutErrors()) { echo $response->getCompiledCode(); } else { echo $code; }
Nette framework:
use GoogleClosureCompiler\Compiler; /** * @var Compiler */ private $compiler; public function __construct(Compiler $compiler) { $this->compiler = $compiler; } public function renderDefault() { $code = file_get_contents('/path/to/script.js'); $response = $this->compiler->setJsCode($code)->compile(); if ($response && $response->isWithoutErrors()) { $code = $response->getCompiledCode(); } $this->template->jsCode = $code; }
And in the config neon
extensions:
- GoogleClosureCompiler\Bridges\Nette\GoogleClosureCompilerExtension
Usage
Direct and main information can be found on https://developers.google.com/closure/compiler/docs/api-ref.
Compiler
Returns GoogleClosureCompiler\Response if connection was successful otherwise returns NULL. setDefaultStreamContextCreateTimeout
Response
Is parsed json from response of previous request.