PHPackages                             smurfy/asseticcssbundleimages-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. smurfy/asseticcssbundleimages-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

smurfy/asseticcssbundleimages-bundle
====================================

Allows you to use the @bundle syntax in your css files

2.2.x-dev(10y ago)92.3kMITPHP &gt;=5.3.0

Since Aug 27Compare

[ Source](https://github.com/smurfy/SmurfyAsseticCssBundleImagesBundle)[ Packagist](https://packagist.org/packages/smurfy/asseticcssbundleimages-bundle)[ Docs](https://github.com/smurfy/SmurfyAsseticCssBundleImagesBundle)[ RSS](/packages/smurfy-asseticcssbundleimages-bundle/feed)WikiDiscussions Synced 2d ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

Provides a new Assetic filter for CSS files which allows you the "@MyBundle" syntax in your CSS. It also exposes DI Container parameters to the CSS File

Example 1 - Using the @MyBundle syntax:
---------------------------------------

[](#example-1---using-the-mybundle-syntax)

`background: url(@MyBundle/Resources/public/images/backgrounds.png);`

Example 2 - Using the DI Container syntax:
------------------------------------------

[](#example-2---using-the-di-container-syntax)

`background: url(%kernel.root_dir%/../vendor/twitter/bootstrap/img/sprite-map.png);`

Example 3 - You even can combine both:
--------------------------------------

[](#example-3---you-even-can-combine-both)

`background: url(@MyBundle/Resources/public/images/%site.mood%/backgrounds.png);`

It also converts all images to assets and allows you to use an existing asset filter for it (like optipng for pngs)

Installation
============

[](#installation)

Symfony 2.1.x
-------------

[](#symfony-21x)

Add the require line to composer.json
-------------------------------------

[](#add-the-require-line-to-composerjson)

```
"require": {
    ....
    "smurfy/asseticcssbundleimages-bundle": "dev-master"
    ...
}

```

and update composer::

```
php composer.phar update

```

Add SmurfyAsseticCssBundleImagesBundle to your application kernel
-----------------------------------------------------------------

[](#add-smurfyasseticcssbundleimagesbundle-to-your-application-kernel)

```
// app/AppKernel.php

public function registerBundles()
{
    return array(
        new Symfony\Bundle\SecurityBundle\SecurityBundle(),
        // ...
        new Smurfy\AsseticCssBundleImagesBundle\SmurfyAsseticCssBundleImagesBundle(),
        // ...
    );
}

```

Symfony 2.0.x
-------------

[](#symfony-20x)

Add SmurfyAsseticCssBundleImagesBundle to your vendor/bundles/ dir
------------------------------------------------------------------

[](#add-smurfyasseticcssbundleimagesbundle-to-your-vendorbundles-dir)

Add the following lines in your `deps` file::

```
[SmurfyAsseticCssBundleImagesBundle]
    git=git://github.com/smurfy/SmurfyAsseticCssBundleImagesBundle.git
    target=bundles/Smurfy/AsseticCssBundleImagesBundle

```

Run the vendors script::

```
./bin/vendors install

```

Add the Smurfy namespace to your autoloader
-------------------------------------------

[](#add-the-smurfy-namespace-to-your-autoloader)

```
// app/autoload.php
$loader->registerNamespaces(array(
    'Smurfy' => __DIR__.'/../vendor/bundles',
    // your other namespaces
);

```

Add SmurfyAsseticCssBundleImagesBundle to your application kernel
-----------------------------------------------------------------

[](#add-smurfyasseticcssbundleimagesbundle-to-your-application-kernel-1)

```
// app/AppKernel.php

public function registerBundles()
{
    return array(
        new Symfony\Bundle\SecurityBundle\SecurityBundle(),
        // ...
        new Smurfy\AsseticCssBundleImagesBundle\SmurfyAsseticCssBundleImagesBundle(),
        // ...
    );
}

```

Configuration
=============

[](#configuration)

By default the filter outputs all files to /assetic/ but you can change that, also you can specify which filter should be used by extention.

```
smurfy_assetic_css_bundle_images:
    output: assetic/*
    absolute: true
    lessUrlRewriteWorkaround: false
    filters:
        png:
            - optipng
        jpg:
            - jpegoptim

```

Sample Usage
============

[](#sample-usage)

In your twig template enable the filter

```
{% stylesheets
    '@MyBundle/Resources/public/css/*' filter='cssbundleimages' output='assetic/*.css'
%}

{% endstylesheets %}

```

After that you can use inside your css file something like that:

```
.body {
    background: url(@MyBundle/Resources/public/images/backgrounds.png);
}

```

LESS Support
============

[](#less-support)

Less is fully supported. Just make sure you load the less filter before the `cssbundleimages` filter.

Be aware, that less does url rewrites of "url" tags if you import other less files in subdirectories and the url tag uses relative aka not beginning with / urls. After that the `cssbundleimages` filter does no longer work, because the url not longer begins with `@BundleName` but with `subdirectory/@BundleName`. There is the `lessUrlRewriteWorkaround` config parameter which allows you to use `/@BundleName`.

```
.body {
    background: url(/@MyBundle/Resources/public/images/backgrounds.png);
}

```

This way less does no url rewrites, because it detects the url as absolute.

Final Notes
===========

[](#final-notes)

Assetic Controller support is working but it always rescans all css files which of course is not so fast. It is recommended to use `assetic:watch` (`assetic:dump --watch` on old versions of assetic bundle) For my Project its ok but it could be a bottleneck in a large development environment.

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1142 days

Total

2

Last Release

3914d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/805790?v=4)[Philipp Andreas](/maintainers/smurfy)[@smurfy](https://github.com/smurfy)

### Embed Badge

![Health badge](/badges/smurfy-asseticcssbundleimages-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/smurfy-asseticcssbundleimages-bundle/health.svg)](https://phpackages.com/packages/smurfy-asseticcssbundleimages-bundle)
```

###  Alternatives

[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[symfony/ai-bundle

Integration bundle for Symfony AI components

32642.2k23](/packages/symfony-ai-bundle)[sylius/inventory-bundle

Flexible inventory management for Symfony applications.

19189.5k6](/packages/sylius-inventory-bundle)[yceruto/formflow-bundle

Create and manage multistep forms

2414.8k](/packages/yceruto-formflow-bundle)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k12](/packages/2lenet-crudit-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
