https://github.com/endroid/asset
Abstraction layer for providing contents from different sources
https://github.com/endroid/asset
Last synced: about 1 year ago
JSON representation
Abstraction layer for providing contents from different sources
- Host: GitHub
- URL: https://github.com/endroid/asset
- Owner: endroid
- License: mit
- Created: 2018-04-08T10:58:56.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2024-10-19T12:37:21.000Z (over 1 year ago)
- Last Synced: 2025-06-12T19:04:20.297Z (about 1 year ago)
- Language: PHP
- Homepage: https://endroid.nl/
- Size: 74.2 KB
- Stars: 9
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Asset
*By [endroid](https://endroid.nl/)*
[](https://packagist.org/packages/endroid/asset)
[](https://github.com/endroid/asset/actions)
[](https://packagist.org/packages/endroid/asset)
[](https://packagist.org/packages/endroid/asset)
Library for quick and easy asset management.
Read the [blog](https://medium.com/@endroid/pdf-generation-in-symfony-3080702353b)
for more information on why I created this library.
* ControllerAsset: generates the string from a controller action and parameters.
* TemplateAsset: generates the string from a template and parameters.
* FileAsset: generates the string by loading the contents of a file.
* UrlAsset: simply contains a string which is returned when requested.
* DataAsset: simply contains a string which is returned when requested.
* CacheAsset: wraps any of the above in a cache to optimize performance.
All implement AssetInterface and provide the method: getData().
## Usage
The easiest way to work with assets is by letting the factory create assets for
you. This allows you to create your assets without worrying about the necessary
dependencies.
```php
$dataAsset = $assetFactory->create([
'controller' => CoverController::class,
'parameters' => ['title' => 'My PDF', 'date' => new DateTime()],
'cache_key' => 'cover',
'cache_expires_after' => 3600,
'cache_clear' => true, // use to purge any previously cached data
]);
```
## Installation
Use [Composer](https://getcomposer.org/) to install the library.
``` bash
$ composer require endroid/asset
```
When you use Symfony, the [installer](https://github.com/endroid/installer)
makes sure that services are automatically wired. If this is not the case you
can find the configuration files in the `.install/symfony` folder.
## Versioning
Version numbers follow the MAJOR.MINOR.PATCH scheme. Backwards compatible
changes will be kept to a minimum but be aware that these can occur. Lock
your dependencies for production and test your code when upgrading.
## License
This bundle is under the MIT license. For the full copyright and license
information please view the LICENSE file that was distributed with this source code.