nvbooster/phpcr-assets-bundle

Bundle for storing and serving js, css assets with PHPCR Storage

Installs: 6

Dependents: 0

Suggesters: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:symfony-bundle

dev-master / 9999999-dev 2016-03-20 05:11 UTC

README

Build Status Scrutinizer Code Quality

Bundle for storing and serving js, css assets with PHPCR Storage.

Install

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(),
        );
    }

Configure

No configuration required for base functionality;

SonataAdmin integration

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: []

CodeMirror integration

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).

Full configuration

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

Using

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.