{"id":18841289,"url":"https://github.com/dmhendricks/php-combine-scripts","last_synced_at":"2025-04-14T07:11:39.453Z","repository":{"id":88694419,"uuid":"195710298","full_name":"dmhendricks/php-combine-scripts","owner":"dmhendricks","description":"A simple PHP script example to combine and minify multiple JS or CSS files passed via URI","archived":false,"fork":false,"pushed_at":"2019-07-13T21:18:47.000Z","size":14,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T12:07:18.323Z","etag":null,"topics":["combine","minify","minify-css","minify-javascript","php","rewrite-urls"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dmhendricks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-08T00:27:12.000Z","updated_at":"2024-12-11T22:38:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"40ddd361-ba5a-4d5a-a79d-4c38f8e349b1","html_url":"https://github.com/dmhendricks/php-combine-scripts","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmhendricks%2Fphp-combine-scripts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmhendricks%2Fphp-combine-scripts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmhendricks%2Fphp-combine-scripts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmhendricks%2Fphp-combine-scripts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmhendricks","download_url":"https://codeload.github.com/dmhendricks/php-combine-scripts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248837287,"owners_count":21169374,"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":["combine","minify","minify-css","minify-javascript","php","rewrite-urls"],"created_at":"2024-11-08T02:50:41.607Z","updated_at":"2025-04-14T07:11:39.434Z","avatar_url":"https://github.com/dmhendricks.png","language":"PHP","readme":"[![Author](https://img.shields.io/badge/author-Daniel%20M.%20Hendricks-lightgrey.svg?colorB=9900cc\u0026style=flat-square)](https://www.danhendricks.com/?utm_source=github.com\u0026utm_medium=campaign\u0026utm_content=button\u0026utm_campaign=dmhendricks%2Fphp-combine-scripts)\n[![License](https://img.shields.io/github/license/dmhendricks/php-combine-scripts.svg?style=flat-square)](https://github.com/dmhendricks/php-combine-scripts/blob/master/LICENSE)\n[![DigitalOcean](https://img.shields.io/badge/hosting-Digital%20Ocean-green.svg?style=flat-square\u0026label=hosting\u0026colorB=0152FF)](https://m.do.co/t/8a88362f5683?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=button\u0026utm_campaign=dmhendricks%2Fphp-combine-scripts)\n[![Twitter](https://img.shields.io/twitter/url/https/github.com/dmhendricks/php-combine-scripts.svg?style=social)](https://twitter.com/danielhendricks)\n\n# PHP Combine Scripts\n\nA simple PHP script to combine and minify multiple JS or CSS files passed via URI, inspired by [jsDelivr](https://www.jsdelivr.com/features/?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=link\u0026utm_campaign=dmhendricks%2Fphp-combine-scripts#combine).\n\nIt was created for when you have multiple scripts at a static/CDN domain, allowing you to pick and bundle different libraries based on your current needs.\n\nGenerally, it is best to combine multiple assets into bundles using a task runner such as [webpack](https://webpack.js.org/?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=link\u0026utm_campaign=dmhendricks%2Fphp-combine-scripts) or [Gulp](https://gulpjs.com/?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=link\u0026utm_campaign=dmhendricks%2Fphp-combine-scripts), but it can be handy depending on your use case.\n\n## Setup\n\n1. Clone or unzip the files to a directory off of your web root. For example, `/combine/`. Change to that directory.\n1. `composer install`\n1. Rename `.env-sample` to `.env`. Set the `COMBINE_BASEDIR` to the directory that will contain your JS/CSS files that you want to allow combining/minification for.\n1. Configure your web server to rewrite URLs, as shown in the examples below. Change the `/combine/` and `/minify/` paths as desired.\n\n### Nginx\n\n```nginx\n# Rewrite combine/minify URLs\nrewrite ^/combine/(.*)$ /combine/index.php?scripts=$1;\nrewrite ^/minify/(.*)$ /combine/index.php?minify=true\u0026scripts=$1;\n```\n\n### Apache\n\n```apache\n# Rewrite combine/minify URLs\nRewriteRule \"^/combine/(.*)$\" \"/combine/index.php?scripts=$1\"\nRewriteRule \"^/minify/(.*)$\" \"/combine/index.php?minify=true\u0026scripts=$1\"\n```\n\n## Usage Example\n\nFor example, let's say that you set your `COMBINE_BASEDIR` to `/var/www/html/scipts/`. Withing this directory, you might have some JS or CSS libraries. We'll combine [Font Awesome](https://fontawesome.com/?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=link\u0026utm_campaign=dmhendricks%2Fphp-combine-scripts) with the [v4 shims](https://fontawesome.com/how-to-use/on-the-web/setup/upgrading-from-version-4/?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=link\u0026utm_campaign=dmhendricks%2Fphp-combine-scripts#shims) as an example, assuming that you have already [extracted them](https://github.com/FortAwesome/Font-Awesome/tree/master/css) to `/var/www/html/scipts/dist/css/`.\n\nTo combine or minify multiple scripts, separate them with commas:\n\n```html\n\u003c!-- Combine example --\u003e\n\u003clink rel=\"stylesheet\" href=\"https://example.com/combine/dist/css/all.min.css,dist/css/v4-shims.min.css\" /\u003e\n\n\u003c!-- Minify example --\u003e\n\u003clink rel=\"stylesheet\" href=\"https://example.com/minify/dist/css/all.css,dist/css/v4-shims.css\" /\u003e\n```\n\nOf course, minification is not necessary for scripts that you already have minified versions for. It is merely an option for libraries/scripts that do not contain a minified version. If you have minified versions avaible, it is recommended to simply use the \"combine\" method as it consumes less system resources.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmhendricks%2Fphp-combine-scripts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmhendricks%2Fphp-combine-scripts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmhendricks%2Fphp-combine-scripts/lists"}