PHP compressor
Build: Master|Develop, (*1)
, (*2)
Highlight
- Merge several files into one file
- Live compiler, fast and no additional program is needed
- Allows user to write code that can be used in other projects ยป Code reuse
- The ability to set variables ยป see variable in help
- Support .css, .fcss and .js files
- Required no changes on the live server
- Reducing server load and client load time
- Optimizing assets for a higher rank in google search results ยป PageSpeed
- Easy to install ยป instalation
- Support for Laravel framework ยป Laravel
Workflow
(Input) (Output)
Root/ . Root/
โโโ Resources/ .. ..................;;. โโโ Public/ (!)
โโโ css/ (!) .. PHP compresspr ;;;;. โโโ compressor/ (static)
โ โโโ table.css . . .::::::::::::::::::;;:' โโโ take.css
โ โโโ alert.css :' โโโ take.js
โ โโโ button.css
โ ...
โโโ js/ (!)
โ โโโ table.js
โ โโโ alert.js
โ โโโ button.js
โ ...
..
(PHP compressor)
PhpCompressor::run(['resources/assets/css/', 'resources/assets/js/'], 'public/');
PhpCompressor::run( [ <loccation> , <location>, ... ], <destination> ); // explanation!
Help, docs and links
Instalation
Install with Laravel
Get PHP compressor by running the composer command in the command line.
```{r, engine='bash', count_lines}
$ composer require bvanhoekelen/php-compressor, (*6)
Open the `AppServiceProvider.php` located in `App\Providers\`.
```php
// Add namespace at the top
use PhpCompressor\PhpCompressor;
// Place the code in the `public function boot()`.
if(config('app.debug')) // DON'T USE ON PRODUCTION !!
PhpCompressor::run(['resources/assets/css/', 'resources/assets/js/'], 'public/');
Place the code in <head>
from the html file., (*7)
<!-- PHP compressor -->
<link href="{{ asset('/compressor/take.css') }}" rel="stylesheet">
<script src="{{ asset('/compressor/take.js') }}"></script>
Install with composer
Get PHP compressor by running the composer command in the command line.
```{r, engine='bash', count_lines}
$ composer require bvanhoekelen/php-compressor, (*8)
Run PHP compressor by place code before the view is draw.
```php
// Require vender autoload
require_once('../vendor/autoload.php');
// Use namespace
use PhpCompressor\PhpCompressor;
// Switch which determines if environment is production
$production = false;
// Run php conpressor
if( ! $production ) // DON'T USE ON PRODUCTION !!
PhpCompressor::run(['resources/css/', 'resources/js/'], 'public/');
Place the code in <head>
from the html file., (*9)
<!-- PHP compressor -->
<link href='compressor/take.css' rel='stylesheet'>
<script src='compressor/take.js'></script>