Bundle for storing and serving js, css assets with PHPCR Storage.
Include this to you composer.json file
"nvbooster/phpcr-assets-bundle": "dev-master"
or run
composer require nvbooster/phpcr-assets-bundle-master
Ensure CmfRoutingAutoBundle is installed and configured according to https://github.com/symfony-cmf/RoutingAutoBundle
Then add PHPCRAssetsBundle to your AppKernel:
public function registerBundles()
{
$bundles = array(
...
new NVBooster\PHPCRAssetsBundle\NVBoosterPHPCRAssetsBundle(),
);
}
No configuration required for base functionality;
To manage assets using SonataAdmin add admin services to sonata config
sonata_admin:
dashboard:
groups:
...
assets:
label: Assets
items:
- nvbooster_assets.js_asset_admin
- nvbooster_assets.css_asset_admin
sonata_doctrine_phpcr_admin:
document_tree:
...
NVBooster\PHPCRAssetsBundle\Asset\JsAsset:
valid_children: []
NVBooster\PHPCRAssetsBundle\Asset\CssAsset:
valid_children: []
To use CodeMirror library for editing assets in SonataAdmin, add codemirror section to config:
nvbooster_assets:
codemirror: ~
If you want for bundle to automatically include js and css files of CodeMirror when needed, then you should provide paths (see Full config).
nvbooster_assets:
phpcr:
root_path: '/cms/assets' #Defines path in PHPCR tree for assets to store in
filters:
css: [] #Default assetics filters for css assets
js: [] #Default assetics filters for js assets
routing:
base_uri: assets #Defines base uri for routes generated
codemirror:
paths:
js: ~ #Path for codemirror.js in web folder
css: ~ #Path for codemirror.css in web folder
modes_dir: ~ #Path for codemirror modes directory in web folder
themes_dir: ~ #Path for codemirror theme styles in web folder
options: #Codemirror widget defaults
mode: xml #Default mode
theme: eclipse #Default theme
After configuring run repository initializers to create all required paths in PHPCR storage:
php app/console doctrine:phpcr:repository:init
Include assets in your templates:
<link rel="stylesheet" href="{{ url(css_asset) }}"/>
<script type="text/javascript" src="{{ url(js_asset) }}"></script>
or any other way.