GitXplorerGitXplorer
e

CC_Service-php

public
2 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
c3441b81fbf589166934c4e86e2a2094772d2f68

Updated archive link in readme

eeyecatchup committed 12 years ago
Unverified
521c0b5980e0e298fcbff79efbce56ce782d8187

Updated pastebin example

eeyecatchup committed 12 years ago
Unverified
0ec2ceee9725582dd01cff42130fdd23eb35134f

Add pastebin.com API to create temporarily public resources from local

eeyecatchup committed 12 years ago
Unverified
bf1914066050718430aa896a88c882a5368b99b9

test commit via giteye

eeyecatchup committed 12 years ago
Unverified
fad14ea866ee298427f23160373faa0043fc559d

Update README.md

committed 13 years ago
Unverified
f481b35914b1bba7f1623e717c2e3ec9cb03ba4f

Update 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