apnet / assetic-importer-bundle
Integrates resource projects into Symfony2
Installs: 1 435
Dependents: 4
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.3.0
- doctrine/lexer: ~1.0
- symfony/assetic-bundle: ~2.3|~3.0
- symfony/config: ~2.3|~3.0
- symfony/dependency-injection: ~2.3|~3.0
- symfony/filesystem: ~2.3|~3.0
- symfony/finder: ~2.3|~3.0
- symfony/http-kernel: ~2.3|~3.0
- symfony/process: ~2.3|~3.0
- symfony/twig-bundle: ~2.3|~3.0
- symfony/yaml: ~2.3|~3.0
- twig/twig: ~1.12
Requires (Dev)
- apnet/coding-standard: ~2.0
- apnet/functional-test-bundle: ~1.2
- covex-nn/twig-callable-bridge-bundle: ~1.1
- knplabs/knp-markdown-bundle: ~1.3
- phpunit/phpunit: ~4.0
- symfony/monolog-bundle: ~2.3
- symfony/symfony: ~2.3|~3.0
Suggests
- symfony/event-dispatcher: ~2.6
This package is not auto-updated.
Last update: 2022-02-01 12:33:38 UTC
README
The main purpose of a Bundle
is to exclude cssrewrite
filter and to bypass known issue
that causes the cssrewrite
to fail when using the @AcmeFooBundle
syntax for CSS Stylesheets.
Bundle
allows you to import files from non-public directories via assetic
directly into routing
.
These files can either be a result of an external program
, or created on the fly from Symfony
.
Bundle
и assetic
keep track of changes to files automatically on every request.
Installation
Add requirements to composer.json:
{ "require" : { "apnet/assetic-importer-bundle" : "~1.0" } }
Register the bundle
Register the bundle in the AppKernel.php
file
// ...other bundles ... $bundles[] = new Apnet\AsseticImporterBundle\ApnetAsseticImporterBundle(); if ($this->getEnvironment() == 'dev') { // ...other bundles ... $bundles[] = new Apnet\AsseticWatcherBundle\ApnetAsseticWatcherBundle(); }
Configuration
Let's assume that you have two directories inside app/Resources
:
app/Resources/simple_dir
withstyle1.css
fileapp/Resources/compass_dir
withconfig.rb
and all other compass-project files (e.g.sass/style2.scss
andstylesheets/style2.css
)
Then add the configuration into your config.yml
apnet_assetic_importer: assets: dir1: source: %kernel.root_dir%/Resources/simple_dir target: example1 dir2: source: %kernel.root_dir%/Resources/compass_dir/config.rb target: example2 importer: compass
After these changes two css files will be accessible via /app_dev.php
/app_dev.php/example1/style1.css
/app_dev.php/example2/stylesheets/style2.css
. Also all files insidecss_dir
,images_dir
,javascripts_dir
,fonts_dir
will ba available.sass_dir
directory contents will be private.
All files will be dumped with assetic:dump
command.
Twig
To include your CSS into Twig template use imported_asset function:
<link href="{{ imported_asset('example1/style1.css') }}" rel="stylesheet" type="text/css" /> <link href="{{ imported_asset('example2/stylesheets/style2.css') }}" rel="stylesheet" type="text/css" />
Assetic Watcher Bundle
Actualy there are two bundles inside apnet/assetic-importer-bundle
:
- Apnet\AsseticImporterBundle
- Apnet\AsseticWatcherBundle
Watcher is a tool, that could be used with dev
environment to compile
compass project without any external file watchers or IDE.
- Of course Apache user needs write permissions to the
compass_dir/stylesheets
directory
AsseticWatcherBundle
is disabled by default.
Configuration
First, to enable Assetic Watcher add these lines to config_dev.yml
apnet_assetic_watcher: compiler_root: %kernel.root_dir%/Resources enabled: true
And second, add watcher
parameter to imported asset configuration in config.yml
apnet_assetic_importer: assets: # ... dir2: source: %kernel.root_dir%/Resources/compass_dir/config.rb target: example2 importer: compass watcher: true