Skip to content

Commit 9242e08

Browse files
committed
Added 'Usage Example' section
1 parent 44ec49a commit 9242e08

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
[![Author](https://img.shields.io/badge/author-Daniel%20M.%20Hendricks-lightgrey.svg?colorB=9900cc&style=flat-square)](https://www.danhendricks.com/?utm_source=github.com&utm_medium=campaign&utm_content=button&utm_campaign=php-combine-scripts)
22
[![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)
3-
[![DigitalOcean](https://img.shields.io/badge/hosting-Digital%20Ocean-green.svg?style=flat-square&label=hosting&colorB=0152FF)](https://m.do.co/t/8a88362f5683?utm_source=github.com&utm_medium=campaign&utm_content=button&utm_campaign=dmhendricks%2Fphp-combine-scripts)
3+
[![DigitalOcean](https://img.shields.io/badge/hosting-Digital%20Ocean-green.svg?style=flat-square&label=hosting&colorB=0152FF)](https://m.do.co/t/8a88362f5683?utm_source=github.com&utm_medium=referral&utm_content=button&utm_campaign=dmhendricks%2Fphp-combine-scripts)
44
[![Twitter](https://img.shields.io/twitter/url/https/github.com/dmhendricks/php-combine-scripts.svg?style=social)](https://twitter.com/danielhendricks)
55

66
# PHP Combine Scripts
77

8-
A 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&utm_medium=campaign&utm_content=button&utm_campaign=php-combine-scripts#combine).
8+
A 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&utm_medium=referral&utm_content=link&utm_campaign=php-combine-scripts#combine).
99

1010
## Setup
1111

1212
1. Clone or unzip the files to a directory off of your web root. For example, `/combine/`. Change to that directory.
1313
1. `composer install`
14-
1. Rename `.env-sample` to `.env`. Change the `COMBINE_BASEDIR` to match your web root.
14+
1. 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.
1515
1. Configure your web server to rewrite URLs, as shown in the examples below. Change the `/combine/` and `/minify/` paths as desired.
1616

1717
### Nginx
@@ -29,3 +29,19 @@ rewrite ^/minify/(.*)$ /combine/index.php?minify=true&scripts=$1;
2929
RewriteRule "^/combine/(.*)$" "/combine/index.php?scripts=$1"
3030
RewriteRule "^/minify/(.*)$" "/combine/index.php?minify=true&scripts=$1"
3131
```
32+
33+
## Usage Example
34+
35+
For 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&utm_medium=referral&utm_content=link&utm_campaign=php-combine-scripts) with the [v4 shims](https://fontawesome.com/how-to-use/on-the-web/setup/upgrading-from-version-4/?utm_source=github.com&utm_medium=referral&utm_content=link&utm_campaign=php-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/`.
36+
37+
To combine or minify Font Awesome 5 and the
38+
39+
```html
40+
<!-- Combine example -->
41+
<link rel="stylesheet" href="https://example.com/combine/dist/css/all.min.css,dist/css/v4-shims.min.css" />
42+
43+
<!-- Minify example -->
44+
<link rel="stylesheet" href="https://example.com/minify/dist/css/all.css,dist/css/v4-shims.css" />
45+
```
46+
47+
Of 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.

0 commit comments

Comments
 (0)