Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dimitribouteille/assets-helper-bundle
https://github.com/dimitribouteille/assets-helper-bundle
asset component css image js php symfony symfony-component
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/dimitribouteille/assets-helper-bundle
- Owner: dimitriBouteille
- License: mit
- Created: 2019-12-18T10:51:24.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-18T11:35:12.000Z (almost 5 years ago)
- Last Synced: 2024-10-01T15:27:52.835Z (about 2 months ago)
- Topics: asset, component, css, image, js, php, symfony, symfony-component
- Language: PHP
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Assets helper bundle
Petit bundle Symfony 4 permettant de gérer un peu plus simplement les chemins vers les images et les fichiers Css et JS. Pour fonctionner, le bundle [Asset Component - Symfony](https://github.com/symfony/asset) doit être installé.
### Installation
```bash
composer require dbout/assets-helper-bundle
```### Utilisation
```php
use Dbout\AssetsHelperBundle\Helper\AssetsHelperInterface;public function contactUs(AssetsHelperInterface $assetsHelper)
{
$css = $assetsHelper->css('app.css');
// Return http://my-site.com/css/app.css
$js = $assetsHelper->css('app.js');
// Return http://my-site.com/js/js.css$picture = $assetsHelper->image('avatar.png');
// Return http://my-site.com/images/avatar.png
}
```dans Twig :
```twig
```### Configuration
Pour fonctionner, le bundle se base sur le bundle [Asset Component - Symfony](https://github.com/symfony/asset). Ainsi, ce bundle doit être [configuré](https://symfony.com/doc/current/reference/configuration/framework.html#assets) avec au minimum les 3 packages suivants :
```yaml
# config/packages/framework.yamlframework:
...
assets:
packages:
css:
base_path: '/css'
js:
base_path: '/js'
image:
base_path: '/images'
```