GitXplorerGitXplorer
e

CC_Service-php

public
2 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
806b8650f38efe5f391681b65565bcf0b37756b2

Update README.md

committed 13 years ago
Unverified
701229fa4b65829298eb23c5483957cc199d332d

Updated example2.php.

committed 13 years ago
Unverified
4a489b43516270431aa1cd20f8efe59160eb6b0e

Fixed typo.

committed 13 years ago
Unverified
9d4c9770e55ab9bd2d9d07d1c1a3193cba9c8f3a

new example2.php

committed 13 years ago
Unverified
73253afff92971099dcd7a5bb2a8d8ef065a4c88

added example.php and example2.php

committed 13 years ago
Unverified
663e7f53250e81f98d40b51212da9c2171718561

added interface note to README.md

committed 13 years ago

README

The README file for this repository.

CC_Service-php

PHP Wrapper Class to communicate with the RESTful Closure Compiler Service API.

This package is intended for use of request compiled JavaScript source code from the Closure Compiler service, by providing methods to send HTTP POST Requests to the Closure Compiler's RESTful Service API.

What is the Closure Compiler?

The Closure Compiler is a tool, developed by Google, for making JavaScript run faster. The clue: Unlike similar tools, it doesn't only shrink the input code. It compiles from JavaScript to better JavaScript.

It parses your JavaScript, analyzes it, removes dead code and rewrites and minimizes what's left. It also checks syntax, variable references, and types, and warns about common JavaScript pitfalls.

More information about the Closure Compiler Service can be found here: https://developers.google.com/closure/compiler/

Download

The latest version can be downloaded as a Zip archive here: https://github.com/eyecatchup/CC_Service-php/archive/master.zip

Usage

Brief example of use

<?php
try {
  // create a new instance of CC_Service
  $cc = new CC_Service();

  // define a new JavaScript resource to be compiled
  $code_url = 'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js';
  $cc->addScript($code_url);

  // optionally, define other request parameters, than defaults
  $cc->setParam('compilation_level', 'WHITESPACE_ONLY');
  $cc->setParam('formatting', 'pretty_print');

  // request compiled the JavaScript from the API
  $compiledJs = $cc->postService();

  header("Content-Type: application/javascript;");
  print($compiledJs);
  // prints the compiled JavaScript
}
catch (CC_Service_Exception $e)
{
  die($e->getMessage());
}

Service interface

The request parameter defaults are set to use the API's defaults. They are explained and can be changed in the class interface https://github.com/eyecatchup/CC_Service-php/blob/master/CC_Service.php#L76

URL: https://github.com/eyecatchup/CC_Service-php/
License: http://eyecatchup.mit-license.org/
(c) 2012, Stephan Schmitz eyecatchup@gmail.com