2017 © Pedro Peláez
 

library google-closure-compiler

PHP client for the Google Closure Compiler API in one file.

image

machy8/google-closure-compiler

PHP client for the Google Closure Compiler API in one file.

  • Thursday, February 1, 2018
  • by Machy8
  • Repository
  • 1 Watchers
  • 4 Stars
  • 372 Installations
  • PHP
  • 1 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 3 % Grown

The README.md

Google Closure Compiler

Build Status Coverage Status License, (*1)

⚡ PHP client for the Google Closure Compiler API in one file., (*2)

Requirements

  • PHP 7.0+
  • If you use Nette Framework - v2.3+

Installation

1 - Download the Google Closure Compiler client using composer:, (*3)

 composer require machy8/google-closure-compiler

2 - Usage:, (*4)

Typical:, (*5)

$compiler = new GoogleClosureCompiler\Compiler;
$response = $compiler->setJsCode($code)->compile();

if ($response && $response->isWithoutErrors()) {
    echo $response->getCompiledCode();

} else {
    echo $code;
}

Nette framework:, (*6)


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, (*7)

extensions:
    - GoogleClosureCompiler\Bridges\Nette\GoogleClosureCompilerExtension

Usage

Direct and main information can be found on https://developers.google.com/closure/compiler/docs/api-ref., (*8)

Compiler

Returns GoogleClosureCompiler\Response if connection was successful otherwise returns NULL. setDefaultStreamContextCreateTimeout, (*9)

Method Parameters Constants
compile
enableClosureCompiler
enableStatistics
excludeDefaultExterns
setCodeUrl string \ string [] $url |
setCompilationLevel string $level COMPILATION_LEVEL_*
setConnectionTimeout                 int $time                             
setExternsUrl string \ string[] $value|
setFormattingType string $type FORMATTING_*
setJsCode string $code
setJsExterns string $jsCode
setLanguage string $language LANGUAGE_*
setLanguageOut string $language LANGUAGE_OUT_*
setOutputFileName string $name
setWarningLevel string $level WARNING_LEVEL_*

Response

Is parsed json from response of previous request., (*10)

Method Returns
getCompiledCode string - compiled code
getErrors array - errors
getOutputFilePath string - url path to file
getResponse stdClass - whole response
getServerErrors array - server errors
getStatistics stdClass - statistics
getWarnings array - warnings
hasErrors bool - if code to compile contains errors
hasServerErrors bool - if response contains server errors
hasWarnings bool - if code to compile contains warnings
isWithoutErrors bool - combination of hasServerErrors & hasErrors

The Versions

01/02 2018

dev-master

9999999-dev

PHP client for the Google Closure Compiler API in one file.

  Sources   Download

BSD-3-Clause New BSD License

The Requires

  • php >=7.0

 

The Development Requires

by Vladimír Macháček

api php javascript google compress minification closure

28/10 2017

v1.0.1

1.0.1.0

PHP client for the Google Closure Compiler API in one file.

  Sources   Download

New BSD License

The Requires

  • php >=7.0

 

The Development Requires

by Vladimír Macháček

api php javascript google compress minification closure

18/10 2017

v1.0.0

1.0.0.0

PHP client for the Google Closure Compiler API in one file.

  Sources   Download

New BSD License

The Requires

  • php >=7.0

 

The Development Requires

by Vladimír Macháček

api php javascript google compress minification closure