{"id":19810243,"url":"https://github.com/mathiasreker/php-script-cache","last_synced_at":"2025-05-01T08:31:43.798Z","repository":{"id":62375686,"uuid":"559640306","full_name":"MathiasReker/php-script-cache","owner":"MathiasReker","description":"php-script-cache is a PHP library for caching external scripts locally.","archived":false,"fork":false,"pushed_at":"2024-11-11T08:36:52.000Z","size":31,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-04-06T11:24:40.591Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MathiasReker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null},"funding":{"github":["MathiasReker"]}},"created_at":"2022-10-30T18:28:08.000Z","updated_at":"2024-12-19T23:29:24.000Z","dependencies_parsed_at":"2022-10-31T19:45:35.922Z","dependency_job_id":null,"html_url":"https://github.com/MathiasReker/php-script-cache","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/MathiasReker%2Fphp-script-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathiasReker%2Fphp-script-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathiasReker%2Fphp-script-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathiasReker%2Fphp-script-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MathiasReker","download_url":"https://codeload.github.com/MathiasReker/php-script-cache/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251847741,"owners_count":21653571,"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":[],"created_at":"2024-11-12T09:20:05.075Z","updated_at":"2025-05-01T08:31:43.522Z","avatar_url":"https://github.com/MathiasReker.png","language":"PHP","funding_links":["https://github.com/sponsors/MathiasReker"],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003ePHP script cache\u003c/h1\u003e\n\n[![Packagist Version](https://img.shields.io/packagist/v/MathiasReker/php-script-cache.svg)](https://packagist.org/packages/MathiasReker/php-script-cache)\n[![Packagist Downloads](https://img.shields.io/packagist/dt/MathiasReker/php-script-cache.svg?color=%23ff007f)](https://packagist.org/packages/MathiasReker/php-script-cache)\n[![CI status](https://github.com/MathiasReker/php-script-cache/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/MathiasReker/php-script-cache/actions/workflows/ci.yml)\n[![Contributors](https://img.shields.io/github/contributors/MathiasReker/php-script-cache.svg)](https://github.com/MathiasReker/php-script-cache/graphs/contributors)\n[![Forks](https://img.shields.io/github/forks/MathiasReker/php-script-cache.svg)](https://github.com/MathiasReker/php-script-cache/network/members)\n[![Stargazers](https://img.shields.io/github/stars/MathiasReker/php-script-cache.svg)](https://github.com/MathiasReker/php-script-cache/stargazers)\n[![Issues](https://img.shields.io/github/issues/MathiasReker/php-script-cache.svg)](https://github.com/MathiasReker/php-script-cache/issues)\n[![MIT License](https://img.shields.io/github/license/MathiasReker/php-script-cache.svg)](https://github.com/MathiasReker/php-script-cache/blob/develop/LICENSE.txt)\n\n`php-script-cache` is a PHP library for caching external scripts locally.\n\n\u003e ✅ Cache\n\u003e ✅ Bundle\n\u003e ✅ Minify\n\n### Versions \u0026 Dependencies\n\n| Version | PHP  | Documentation |\n|---------|------|---------------|\n| ^1.0    | ^7.4 | current       |\n\n### Requirements\n\n- `PHP` \u003e= 7.4\n- php-extension `ext-json`\n\n### Installation\n\nRun:\n\n```bash\ncomposer require mathiasreker/php-script-cache\n```\n\n### Examples\n\nSet up a cronjob to build the assets.\n\n```php\n\u003c?php\n\nuse MathiasReker\\PhpScriptCache\\ScriptCache;\n\nrequire __DIR__ . '/vendor/autoload.php';\n\n(new ScriptCache())\n    -\u003esetPath(__DIR__ . '/assets/js')\n    -\u003edoMinify()\n    -\u003eadd([\n        'src' =\u003e [\n            'https://example1.com/script.js',\n            'https://example2.com/script.js'\n        ], // multiple scripts will get bundled\n    ])\n    -\u003eadd([\n        'src' =\u003e ['https://example3.com/script.js'],\n    ])\n    -\u003ebuild();\n```\n\nPlace this code where you want to output the script tags. You can add attributes to the scripts.\n\n```php\n\u003c?php\n\nuse MathiasReker\\PhpScriptCache\\ScriptCache;\n\nrequire __DIR__ . '/vendor/autoload.php';\n\n$result = (new ScriptCache())\n    -\u003esetPath(__DIR__ . '/assets/js')\n    -\u003eadd([\n        'src' =\u003e [\n            'https://example1.com/script.js',\n            'https://example2.com/script.js'\n        ],\n    ])\n    -\u003eadd([\n        'src' =\u003e ['https://example3.com/script.js'],\n        'id' =\u003e 'test',\n        'defer' =\u003e '',\n    ])\n    -\u003efetch();\n\n // Result: \u003cscript src=\"/assets/js/c5a80e42.js?v=ec25a610\"\u003e\u003c/script\u003e\u003cscript src=\"/assets/js/c5a80e42.js?v=539e4fd1\" id=\"test\" defer\u003e\u003c/script\u003e\n```\n\n### Documentation\n\nInstantiate the object.\n\n```php\n$result = new ScriptCache();\n```\n\n```php\n$result-\u003esetPath(__DIR__ . '/assets/js');\n```\n\n`setPath` sets the path of the output folder for built files.\n\n```php\n$result-\u003edoMinify();\n```\n\n`doMinify` minifies the content.\n\n```php\n$result-\u003eadd(['src' =\u003e ['https://example.com/script.js']]);\n```\n\n`add` sets the attributes of the script. The `src` can be an array of several scripts.\nAll the scripts in the collection will get bundled. You can use any attributes.\nYou do not need to set attributes when you build the cache.\n\n```php\n$result-\u003ebuild();\n```\n\n`build` builds the assets.\n\n```php\n$result-\u003efetch();\n```\n\n`fetch` returns a string of the script tags.\n\n### Roadmap\n\nSee the [open issues](https://github.com/MathiasReker/php-script-cache/issues) for a complete list of proposed\nfeatures (and known issues).\n\n### Contributing\n\nIf you have a suggestion to improve this, please fork the repo and create a pull request. You can also open an issue\nwith the tag \"enhancement\". Finally, don't forget to give the project a star! Thanks again!\n\n#### Docker\n\nIf you are using docker, you can use the following command to get started:\n\n```bash\ndocker-compose up -d\n```\n\nNext, access the container:\n\n```bash\ndocker exec -it php-script-cache bash\n```\n\n#### Tools\n\nPHP Coding Standards Fixer:\n\n```bash\ncomposer cs-fix\n```\n\nPHP Coding Standards Checker:\n\n```bash\ncomposer cs-check\n```\n\nPHP Stan:\n\n```bash\ncomposer phpstan\n```\n\nUnit tests:\n\n```bash\ncomposer test\n```\n\n### License\n\nIt is distributed under the MIT License. See `LICENSE` for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathiasreker%2Fphp-script-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathiasreker%2Fphp-script-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathiasreker%2Fphp-script-cache/lists"}