Recommend this page to a friend! |
Classes of Josantonius | PHP Asset | README.md | Download |
|
DownloadPHP Asset libraryPHP library for handling styles and scripts; Add, minify, unify and print.
RequirementsThis library is supported by PHP versions 5.6 or higher and is compatible with HHVM versions 3.0 or higher. InstallationThe preferred way to install this extension is through Composer. To install PHP Asset library, simply:
The previous command will only install the necessary files, if you prefer to download the entire source code you can use:
You can also clone the complete repository with Git:
Or install it manually:
Available MethodsAvailable methods in this library: - Add scripts or styles:
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $type | 'script' or 'style' | string | Yes | | | Attribute | key | Description | Type | Required | Default | --- | --- | --- | --- | --- | --- | | $data | | Settings | array | Yes | | | | name | Unique ID | string | Yes | | | | url | Url to file | string | Yes | | | | version | Version | string | No | false | | | footer | Only for scripts - Attach in footer | boolean | No | true | | | attr | Only for scripts - Attribute (defer/sync) | string | No | | # Return (boolean) - Check if a particular style or script has been added:
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $type | 'script' or 'style' | string | Yes | | | $name | Unique ID | string | Yes | | # Return (boolean) - Remove script or style:
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $type | 'script' or 'style' | string | Yes | | | $name | Unique ID | string | Yes | | # Return (boolean true) - Sets whether to merge the content of files into a single file:
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $uniqueID | Unique identifier for unified file | string | Yes | | | $params | Path urls | mixed | Yes | | | $minify | Minimize file content | boolean | No | false | # Return (boolean true) - Output stylesheet:
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $output | Output for styles | string | No | '' | # Return (string|false) ? Output or false - Output scripts:
| Attribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $place | 'header' or 'footer' | string | Yes | | | $output | Output for scripts | string | No | '' | # Return (string|false) ? Output or false Quick StartTo use this class with Composer:
Or If you installed it manually, use it:
UsageExample of use for this library: - Add styles:
- Add scripts:
- Check if resources have been added correctly:
- Delete added resources:
- Unify:
- Unify and minify:
- Unify specifying different url paths for styles and scripts:
- Unify and minify specifying different url paths for styles and scripts:
- Output styles:
- Output footer scripts:
- Output header scripts:
TestsTo run tests you just need composer and to execute the following:
Run unit tests with PHPUnit:
Run PSR2 code standard tests with PHPCS:
Run PHP Mess Detector tests to detect inconsistencies in code style:
Run all previous tests:
? TODO
ContributeIf you would like to help, please take a look at the list of issues or the To Do checklist. Pull requests
RepositoryThe file structure from this repository was created with PHP-Skeleton. LicenseThis project is licensed under MIT license. See the LICENSE file for more info. Copyright2016 - 2018 Josantonius, josantonius.com If you find it useful, let me know :wink: |