{"id":19559349,"url":"https://github.com/machy8/google-closure-compiler","last_synced_at":"2025-04-26T23:32:31.195Z","repository":{"id":57015908,"uuid":"104569043","full_name":"Machy8/google-closure-compiler","owner":"Machy8","description":"⚡ PHP client for the Google Closure Compiler API in one file.","archived":false,"fork":false,"pushed_at":"2018-02-01T20:22:06.000Z","size":25,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-10T20:35:58.237Z","etag":null,"topics":["api","closure","compress","google","javascript","minification","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Machy8.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-23T13:21:06.000Z","updated_at":"2024-08-29T11:19:23.000Z","dependencies_parsed_at":"2022-08-22T09:31:48.193Z","dependency_job_id":null,"html_url":"https://github.com/Machy8/google-closure-compiler","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Machy8%2Fgoogle-closure-compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Machy8%2Fgoogle-closure-compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Machy8%2Fgoogle-closure-compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Machy8%2Fgoogle-closure-compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Machy8","download_url":"https://codeload.github.com/Machy8/google-closure-compiler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224050889,"owners_count":17247379,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","closure","compress","google","javascript","minification","php"],"created_at":"2024-11-11T05:00:20.509Z","updated_at":"2024-11-11T05:01:22.792Z","avatar_url":"https://github.com/Machy8.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Google Closure Compiler\n[![Build Status](https://travis-ci.org/Machy8/google-closure-compiler.svg?branch=master)](https://travis-ci.org/Machy8/google-closure-compiler)\n[![Coverage Status](https://coveralls.io/repos/github/Machy8/google-closure-compiler/badge.svg?branch=master)](https://coveralls.io/github/Machy8/google-closure-compiler?branch=master)\n[![License](https://img.shields.io/badge/license-New%20BSD-blue.svg)](https://github.com/Machy8/google-closure-compiler/blob/master/license.md)\n\n⚡ PHP client for the [Google Closure Compiler](https://closure-compiler.appspot.com/home) API in one file.\n\n## Requirements\n- PHP 7.0+\n- If you use Nette Framework - v2.3+\n\n## Installation\n**1 - Download the Google Closure Compiler client using composer:**\n```\n composer require machy8/google-closure-compiler\n```\n**2 - Usage:**\n\n*Typical:*\n\n```php\n$compiler = new GoogleClosureCompiler\\Compiler;\n$response = $compiler-\u003esetJsCode($code)-\u003ecompile();\n\nif ($response \u0026\u0026 $response-\u003eisWithoutErrors()) {\n    echo $response-\u003egetCompiledCode();\n\n} else {\n    echo $code;\n}\n\n```\n\n*Nette framework:*\n```PHP\n\nuse GoogleClosureCompiler\\Compiler;\n\n/**\n * @var Compiler\n */\nprivate $compiler;\n\n\npublic function __construct(Compiler $compiler) \n{\n    $this-\u003ecompiler = $compiler;\n}\n\n\npublic function renderDefault() \n{\n    $code = file_get_contents('/path/to/script.js');\n    $response = $this-\u003ecompiler-\u003esetJsCode($code)-\u003ecompile();\n    \n    if ($response \u0026\u0026 $response-\u003eisWithoutErrors()) {\n        $code = $response-\u003egetCompiledCode();\n    }\n    \n    $this-\u003etemplate-\u003ejsCode = $code;\n}\n```\n\nAnd in the config neon\n```\nextensions:\n    - GoogleClosureCompiler\\Bridges\\Nette\\GoogleClosureCompilerExtension\n```\n\n## Usage\nDirect and main information can be found on [https://developers.google.com/closure/compiler/docs/api-ref](https://developers.google.com/closure/compiler/docs/api-ref).\n\n### Compiler\nReturns [GoogleClosureCompiler\\Response](https://github.com/Machy8/google-closure-compiler/blob/master/src/Compiler/Response.php) if connection was successful otherwise returns NULL.\nsetDefaultStreamContextCreateTimeout\n\n|         Method                        |        Parameters        |      Constants      |\n|---------------------------------------|--------------------------|---------------------|\n| compile                               |                          |                     |\n| enableClosureCompiler                 |                          |                     |\n| enableStatistics                      |                          |                     |\n| excludeDefaultExterns                 |                          |                     |\n| setCodeUrl                            | string \\| string [] $url |                     |\n| setCompilationLevel                   | string $level            | COMPILATION_LEVEL_* |\n| setConnectionTimeout                  | int $time                |                     |\n| setExternsUrl                         | string \\| string[] $value|                     |\n| setFormattingType                     | string $type             | FORMATTING_*        |\n| setJsCode                             | string $code             |                     |\n| setJsExterns                          | string $jsCode           |                     |\n| setLanguage                           | string $language         | LANGUAGE_*          |\n| setLanguageOut                        | string $language         | LANGUAGE_OUT_*      |\n| setOutputFileName                     | string $name             |                     |\n| setWarningLevel                       | string $level            | WARNING_LEVEL_*     |\n\n### Response\nIs parsed json from response of previous request.\n\n|          Method         |                      Returns                      |\n|-------------------------|---------------------------------------------------|\n| getCompiledCode         | string - compiled code                            |\n| getErrors               | array - errors                                    |\n| getOutputFilePath       | string - url path to file                         |\n| getResponse             | stdClass - whole response                         |\n| getServerErrors         | array - server errors                             |\n| getStatistics           | stdClass - statistics                             |\n| getWarnings             | array - warnings                                  |\n| hasErrors               | bool - if code to compile contains errors         |\n| hasServerErrors         | bool - if response contains server errors         |\n| hasWarnings             | bool - if code to compile contains warnings       |\n| isWithoutErrors         | bool - combination of hasServerErrors \u0026 hasErrors |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmachy8%2Fgoogle-closure-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmachy8%2Fgoogle-closure-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmachy8%2Fgoogle-closure-compiler/lists"}