netresearch / assetpicker-bundle
Symfony Bundle for [AssetPicker](https://github.com/netresearch/assetpicker)
Requires
- netresearch/assetpicker: ^1.2.2
This package is auto-updated.
Last update: 2024-11-18 02:55:35 UTC
README
This Symfony bundle provides the AssetPicker sources to Symfony Applications along with view helpers and a proxy controller.
Installation
-
Install via composer
composer require assetpicker-bundle
-
Enable the bundle
-
Add AssetPicker configuration to your
app/config/config.yml
asset_picker: storages: entermediadb: adapter: entermediadb url: "http://em9.entermediadb.org/openinstitute" proxy: true github: username: "netresearch" repository: "assetpicker"
-
(Optional) If you want to use the builtin proxy controller, you must include its routes into
app/config/routing.yml
- the correct proxy url will then be set automatically:assetpicker_proxy: resource: "@AssetPickerBundle/Resources/config/routing.yml"
-
Clear cache and install the assets
php app/console cache:clear php app/console assets:install
Usage
The bundle provides two twig functions: assetpicker_config
and assetpicker_url
. The first returns a JSON representation of the config from your app/config/config.yml
(eventually with the proxy url added) and the second gives you the url to the picker.js inside your assets path (usually /web/bundles/assetpicker/js/picker.js). You can use them as follows:
<script type="text/javascript" src="{{ assetpicker_url() }}"></script> <script type="text/javascript"> new AssetPicker({{ assetpicker_config() }}); </script> <button rel="assetpicker">Pick an asset</button>