Git Product home page Git Product logo

assetmanager's Introduction

AssetManager

By Wesley Overdijk and Marco Pivetta

Build Status Latest Stable Version

⚠️ No longer maintained

Every now and then a PR might be merged, but it's probably for the best to use a fork.

PRs without enough reputable approvals will not be merged.

Introduction

This module is intended for usage with a default directory structure of a LaminasSkeletonApplication. It provides functionality to load assets and static files from your module directories through simple configuration. This allows you to avoid having to copy your files over to the public/ directory, and makes usage of assets very similar to what already is possible with view scripts, which can be overridden by other modules. In a nutshell, this module allows you to package assets with your module working out of the box.

Installation

  1. Require assetmanager:
./composer.phar require rwoverdijk/assetmanager
# When asked for a version, type "2.*" when using Laminas. When using Zend Framework type "1.*"

Usage

Take a look at the wiki for a quick start and more information. A lot, if not all of the topics, have been covered in-dept there.

Sample module config:

<?php
return array(
    'asset_manager' => array(
        'resolver_configs' => array(
            'collections' => array(
                'js/d.js' => array(
                    'js/a.js',
                    'js/b.js',
                    'js/c.js',
                ),
            ),
            'paths' => array(
                __DIR__ . '/some/particular/directory',
            ),
            'map' => array(
                'specific-path.css' => __DIR__ . '/some/particular/file.css',
            ),
        ),
        'filters' => array(
            'js/d.js' => array(
                array(
                    // Note: You will need to require the classes used for the filters yourself.
                    'filter' => 'JSMin',
                ),
            ),
        ),
        'view_helper' => array(
            'cache'            => 'Application\Cache\Redis', // You will need to require the factory used for the cache yourself.
            'append_timestamp' => true,                      // optional, if false never append a query param
            'query_string'     => '_',                       // optional
        ),
        'caching' => array(
            'js/d.js' => array(
                'cache'     => 'Apc',
            ),
        ),
    ),
);

Please be careful, since this module will serve every file as-is, including PHP code.

Questions / support

If you're having trouble with the asset manager there are a couple of resources that might be of help.

Todo

The task list has been slimmed down a lot lately. However, there are still a couple of things that should be done.

  • Renewing the cache

assetmanager's People

Contributors

adamturcsan avatar akomm avatar basz avatar chaos0815 avatar evandotpro avatar exptom avatar fabiankoestring avatar hummer2k avatar internalsystemerror avatar jaapmoolenaar avatar jmleroux avatar lcf avatar mabuzagu avatar mariokostelac avatar matiasfuster avatar michaelmoussa avatar nosenaoki avatar ocramius avatar ojhaujjwal avatar pensiero avatar rwoverdijk avatar skors avatar spiffyjr avatar thomasvargiu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

assetmanager's Issues

index.php return php content when called directly

it seems that when asset manager is loaded in module chain and you call your zf2 project like zf2project.com/index.php the server responses with the plain index.php content. can somebody reproduce this bug?

Cache warmup / renewal

The asset manager misses the possibility to warm up or renew the cache. This should be added for version 1.2.0, which will have multiple mayor updates.

This feature should allow the user to supply a warmup cache, with either paths or full urls to visit in order to warm up the cache. Replacing the cache will be done in an optimal manner. First we'll apply filters, and then, with the temp data in place, we'll run the cacher. Including this issue I will also move the filters and caching to their own locations as the AssetManager is starting to get crowded.

Zend Version

Can the composer.json file be changed so that zendframework requires 2.* instead of 2.0.*, im currently using the 2.1-dev branch and its stopping me from being able to use assetmanager.

Wiki for resolvers.

I should really add an entry to the wiki explaining resolvers more in dept.

Contemplate using pluginmanager

Recently I dived into all service locators, including the abstract plugin manager (uses service manager). I think that converting to a pluginmanager might be a good idea, as it sort of makes sense.

Upsides

  • Well known behaviour.
  • Full power of services, in stead of a limited implementation.
  • Centralized plugin validation.

Downside

  • Config will be separated, unless it is specified as a service (array) or I share the config with the pluginmanager.

This is not a very important issue. I will look at this when I find the time.

[Question] How to serve file hash

Hello,

I'm using the FilesystemCache for my assets but i don't know how to get the resulting hash to use it in my view template.

My asset (a css file foo.css), is hashed and i can view it in public/assets/application/808cc956bac63457eb33ca3edd9a4949.

Isn't this the right way to use assets in view layout ?

$this->headLink()->prependStylesheet(basePath('/assets/application/foo.css'));

Output

<link type="text/css" rel="stylesheet" media="screen" href="/mysite/public/assets/application/foo.css">

but i want something like this :

<link type="text/css" rel="stylesheet" media="screen" href="/mysite/public/assets/application/808cc956bac63457eb33ca3edd9a4949">

Add route

Would it be possible, to specify a route for the module so that for instance, I can set a base path of '/assets/', so that http://domain.com/assets/css/test.css would be handled by the AssetManager, but anything outside of that route wouldn't be?

asset_groups

Currently we have a couple of configurable options:

  • map
  • paths
  • prioritized_paths
  • resolvers
  • etc.

We are already going to have a couple of new ones:

  • filters
  • caching

I want to also add one named asset_groups which basically is an alias. All entries per asset_group will be resolved individually. Example:

<?php
return array(
    'asset_groups' => array(
        'js/my_collection.js' => array(
            'js/some_file.js',
            'js/somedir/',
            'js/my_files/a.js',
            'js/my_files/b.js',
            'js/my_files/c.js',
        ),
    ),
    'map' => array(
        'js/some_file.js' => __DIR__ . '/../public/js/some_file.js',
    ),
    'paths' => array(
        __DIR__ . '/../public'
    ),
);

Ideally every file added in the asset_groups also has an entry in the map. Every directory added in the asset_group will result in every file in that directory being added. This feature should not be used a lot because of obvious reasons.

Please note: The key of this group is just an alias.*
After defining this alias, all filters, and caching will be applied to that alias, and not the files residing inside of that alias.

Filtering collection

Is it possible to apply filters on collection after all assets are glued together, instead of applying filter to each asset in collection?

AssetManager\Service\MimeResolver should resolve extensions case-insensitive

The MimeResolver only resolves extensions in lower case notation.

pathinfo(...) may return the extension as it is. E. g. : filename.PDF > 'PDF'.
Since there is only a 'pdf' key in the $mimeTypes hash, the method would return 'text/plain' .

Changing:
$extension = pathinfo($filename, PATHINFO_EXTENSION);
to:
$extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION));

Should solve the Problem.

Assetic version on composer.json

I was trying to setup caching in the SxBootstrap module, and I got an error about ApcCache class not found. I dig up a bit and found that I was using version 1.2.4 of AssetManager. I wondered why my composer wasn't updating to the new 1.2.6 version, and after I while I think I got it. Newer versions of AssetManager are requiring an alpha version of Assetic, since composer's default minimum-stability is stable, it doesn't download it, so it only download version 1.2.4.

If I force: "kriswallsmith/assetic": ">=1.1.0-alpha1@alpha" on my project's composer.json, I can get the correct version of AssetManager, so I wonder if you should use the @alpha.

Console response issue

If you run console request to application which use AssetManager you will get an exception:

Call to undefined method Zend\Console\Response::getStatusCode() in /zend2/vendor/rwoverdijk/assetmanager/src/AssetManager/Module.php on line 55

Problem in the following code:

if ($response->getStatusCode() !== 404) {
    return;
}

Cache-control header support?

Looks like there's no easy way to control "Cache-control" header for assets served by AssetManager (or, I'm missing something in here). I'm always getting "no-store, no-cache, must-revalidate, post-check=0, pre-check=0" and can't benefit from browser's cache. Would be nice to have such control from within the configuration.

Return 304 - Not Modified

Hi,
You always return 200, but what do you think based in If-Modified-Since header return 304 to avoid unnecessary trafic?

Using CollectionResolver, Filesystem cache returns same results for different assets.

Hi.

I use AssetManager for my project. it helps us very well. Thank you for creating great product.

Now, I saw some problem today as described in title.
Could you give me any advice to solve this problem?

below is a detailed report.

repro steps

  1. module configuration is like following.
return array(
    'asset_manager' => array(
        'resolver_configs' => array(
            'collections' => array(
                'js/e.js' => array(
                    'js/a.js',
                    'js/b.js',
                ),
                'js/f.js' => array(
                    'js/c.js',
                    'js/d.js',
                ),

            ),
            'paths' => array(
                __DIR__ . '/../public',
            ),
        ),
        'caching' => array(
            'default' => array(
                'cache'     => 'Filesystem',
                'options' => array (
                    'dir' => 'data/cache/assets'
                ),
            ),
        ),
);
  1. open "js/e.js" with a browser , and then, open "js/f.js".

[a-e].js has defferent content.

expected behavior

"js/f.js" shows different result from "js.e.js".

actual behavior

"js/f.js" shows same result as "js.e.js".

I created the minimum project to reproduce this problem here.
Please refer to it , if you like.

Rework resolver service factory to allow custom priorities and resolvers

We need to implement some logic to allow custom asset resolvers (any number of asset resolvers). Basically, the config can be reworked in following:

<?php
return array(
    'asset_manager' => array(
        'map' => array(/* usual map resolver config */),
        'paths' => array(/* usual paths resolver config */),
        'asset_collections' => array(/* tbd, mainly for assetic asset collections */),

        // new config key
        'resolvers' => array(
            // key is a service name, value is the priority for the resolver in the queue
            'AssetManager\Resolver\MapResolver' => 1000,
            'AssetManager\Resolver\PathStackResolver' => 1,
            'AssetManager\Resolver\AssetCollectionResolver' => 500,
            // 'user_defined_resolver' => 1234
        ),
    ),

    'service_manager' => array(
        'factories' => array(
            // new factories to be implemented, they still use config.asset_manager.map|path|asset_collections
            'AssetManager\Resolver\MapResolver'       => 'AssetManager\Service\MapResolverServiceFactory',
            'AssetManager\Resolver\PathStackResolver'         => 'AssetManager\Service\PathStackResolverServiceFactory',
            'AssetManager\Resolver\AssetCollectionResolver'  => 'AssetManager\Service\AssetCollectionResolverServiceFactory',

            'AssetManager\Service\ResolverInterface' => 'AssetManager\Service\AggregateResolverServiceFactory',
        ),
    ),
);

Summarizing:

  1. AssetManager\Service\ResolverServiceFactory to be refactored to look for config.asset_manager.resolvers (as a $serviceName => $priority array).
  2. Build 2 factories for MapResolver and PathStack (each still using previous config)
  3. Test each factory (suggestion: test the new aggregate resolver factory by defining mock objects as services)
  4. Eventually start work on the AssetCollections resolver, but it is tricky since it doesn't resolve to a file

Working with .less files and LessphpFilter

When you are working with .less files and apply the 'Lessphp' filter from assetic, the Service/MimeResolver.php returns 'text/plain' because 'less' extension is not listed in the $mimeTypes collection.

As effect, the css is loaded but not applied.

https://github.com/RWOverdijk/AssetManager/blob/master/src/AssetManager/Service/MimeResolver.php#L550

'asset_manager' => array(
        'resolver_configs' => array(
            'map' => array(
                'css/bootstrap.css' => 'path/to/bootstrap/bootstrap.less',
            ),
        ),
        'filters' => array(
            'css/bootstrap.css' => array(
                array(
                    'filter' => 'Lessphp',
                )
            ),
        ),
    ),

Allow for collection files to be absolute.

When creating a collection it might be wise to also check if the passed value perhaps links to an already existing file. If this is the case, then just fetch it and skip resolving.

It might be smart to take this one step further and always check if a file exists, in the AggregateResolver.

Test in php 5.4

  1. Setup skeleton with AssetManager
  2. Add asset
  3. cd into the public directory
  4. php -S localhost:8080
  5. Test

Publish assets

AssetManager should have a way to collect all assets during the build process so static content could be deployed to CDN.

Requirements:

  • view helper for static content location (path on development and production will be different)
    • configuration will hold CDN location. Setting this will essentially //disable// AssetManager on production (there won't be any calls to AssetManager as all asset requests will go to CDN).
  • cli controller to collect all static content managed by AssetManager

Any suggestions?

Applying filters

When I add to config filters like that

'filters' => array(
    'css/application/test.css' => array(
        array(
            'filter' => 'JSMinFilter', // 'CssMinFilter', 
        ),
    ),
),

kriswallsmith/assetic package throws exceptions like this

Fatal error: Class 'JSMin' not found in /var/www/zend-skeleton/vendor/kriswallsmith/assetic/src/Assetic/Filter/JSMinFilter.php on line 32

I know ithis isse is related more to kriswallsmith/assetic package then yours but probably I'm doing smth wrong?!

v2

This is a general discussion for AssetManager V2. We'll be collecting things to be done and discuss them as well.

  • Last modified #130
  • @iwalz collection #75
  • Cache warmup #40
  • Static file cache #76
  • Serving collections and naming of config keys #102
  • Serving hash-based #99
  • Safe names (is this actually an issue?) #107
  • Better filters #109
  • Filters and collections #110
  • Resolvers shouldn't implement setAggregateResolver
  • CDN / publish assets #131
  • Wildcard cache #121
  • Wildcards in general

Automatically minify

Would it be possible to use AssetManager to listen for the render event and then to cycle through headStyle, headScript and inlineScript to automatically minify those files and then replace the array with the single minified file?

Serve collections without serve single files

Hi,
I'm using AssetManager with a collection resolver, but I think there is a security issue.

I have a situation like this

   'resolver_configs' => array(
        'collections' => array(
            'css/style.css' => array(
                'css/lessfile1.css',
                'css/lessfile2.css',
            ),
           ),

        'paths' => array(
            __DIR__ . '/../public',
        ),
    ),

       'filters' => array(
        'css/style.css' => array(
            array(
                'filter' => 'Lessphp',
            ),
        ),

This works correctly. I can see /css/style.css correctly. The security problem is related to paths. To use a collection I need to configure a path that expose my single files.
I want to serve only files merged and compressed, because in single files there are a lot of team's comments.

An easy solution could be like this:

     'resolver_configs' => array(
        'collections' => array(
            'css/style.css' => array(
                  __DIR__ . '/../public/css/lessfile1.css',
                  __DIR__ . '/../public/css/lessfile2.css',
            ),
           ),
    ),

       'filters' => array(
        'css/style.css' => array(
            array(
                'filter' => 'Lessphp',
            ),
        ),

But this doesn't work because I think that a collection expect an alias and not a path. Is there another solution?

A Collection of .less files is compiled file by file, but should be compiled concatenated

Hi folks,

I'm trying to combine multiple less files, Bootstrap 3 for example, to compile via lessphp filter.

When using a collection with multiple .less files, it fails, because every less file is compiled for its own, so dependencies won't work.

I tried to create my own Resolver for concatenation and apply Lessphp filter on the collection of the less files. Concat works, but no Filter is applied. Even if i add the filter on a new, second collection.

So after all, it would be nice if a Collection could be sum up to one Content (for example String Asset) and then Filters would be applied afterwards.

Maybe I getting something wrong. Here is some Example Code: http://pastie.org/8410299

Thanks in advance,

Sebastian

Missing rawurldecode()

Is this module deliberately not rawurldecode()ing paths? For instance, it doesn't work with spaces in file names since it looks for a%20file%20like%20this instead of a file like this.

The following code in `AssetManager/Service/AssetManager.php`` after line 172 in Version 1.3.4 would fix this:

$nameParts = explode('/', $path);
foreach ($nameParts as &$part) {
    $part = rawurldecode($part);
}
$path = join('/', $nameParts);

Plan architecture of the asset dumper

Asset dumping (or "cache warmup") is a huge question mark to be solved soon, as users will most probably need it in production. This will probably mean that we need to extend the asset resolvers so that they can return a map of all existing assets.

Is it possible to do wildcard caching?

The fact nobody else has asked this makes me feel a little silly but, is it possible to cache via wildcard in config? *.css, *.js, *.jpg, *.png, *.html

I assume the resolver takes an array config of files it can pass you straight through to when a request comes through... perhaps there is a generator?

I ask as when I use a module that hasn't enabled caching for it's assets, I need to add them all and it's a little monotonous adding say... 30 assets.

Duplicate tags

This return duplicate and script tags.

One group tags is in

and other in

headLink()->prependStylesheet($this->basePath() . '/css/test.css');?> headScript()->prependFile($this->basePath() . '/js/base.js', 'text/javascript');?>

Can't get aliases work as expected

Hi,

first of all thanks for this module, it's very useful stuff when building ZF2 based projects. But I have some troubles trying to get it work accordingly to my preference.

I followed your quick guide and it worked fine. But obviously it's ridiculous to put all your assets (css, js, images) into one single directory. I have common file structure in MyModule/public durectory. There are 3 folders css, js, images. What I want to do is simply load my files one by one. I was successful when I did it like that:

<?php 
return array(
    'asset_manager' => array(
        'resolver_configs' => array(
            'paths' => array(
                __DIR__ . '/../public',
            ),
        ),
    ),
);
<?php echo $this->headLink()
    ->prependStylesheet($this->basePath() . '/css/one.css')
    ->prependStylesheet($this->basePath() . '/css/two.css') ?>

But if I do it this way I could face with namespace issue when there will be several /css/one.css. So basically I should use aliases, prepending file path with mymodule alias. Something like this:

<?php echo $this->headLink()
    ->prependStylesheet($this->basePath() . '/mymodule/css/one.css')
    ->prependStylesheet($this->basePath() . '/mymodule/css/two.css') ?>

And here is where I'm stuck. I tried several resolvers and their combinations and none of them works for me. Here are configs that I was trying to use. This one returns blank page:

<?php 
return array(
    'asset_manager' => array(
        'resolver_configs' => array(
            'prioritized_paths' => array(
                 array(
                    'mymodule'      => __DIR__ . '/../public',
                    'priority'  => 100,
                ),
            ),
        ),
    ),
);

And this one returns 404:

<?php 
return array(
    'asset_manager' => array(
        'resolver_configs' => array(
            'map' => array(
                'mymodule'      => __DIR__ . '/../public',
            ),
        ),
    ),
);

While this works:

<?php 
return array(
    'asset_manager' => array(
        'resolver_configs' => array(
            'map' => array(
                'mymodule/css/one.css'      => __DIR__ . '/../public/css/one.css',
            ),
        ),
    ),
);

But this last doesn't suit for my needs since I have a lot of asset files and I don't want to list them all and modify config every time I add/remove them. So my question is is there a way to create aliases to whole directory to be able to load them this way:

<?php echo $this->headLink()
    ->prependStylesheet($this->basePath() . '/alias/css/one.css')
    ->prependStylesheet($this->basePath() . '/alias/css/two.css') ?>

Map resolver should use name instead of path as option for MimeType resolver?

Hello.

I am not sure if its an issue buts it become small problem for me.

I f you have some asset for MapResolver like this:
'twitter/bootstrap.css' => DIR . '/../assets/twitter/bootstrap.less',
later this asset filtered by LessPHP and become CSS file.

But its type is text/plain (so CSS styles don't works) bacause of this:

MapResolver

public function resolve($name)
{
    if (!isset($this->map[$name])) {
        return null;
    }

    $file            = $this->map[$name];
    $mimeType        = $this->getMimeResolver()->getMimeType($file);
    $asset           = new FileAsset($file);
    $asset->mimetype = $mimeType;

    return $asset;
}

I think in the case of MapResolver it should be better to replace getMimeType($file) -> getMimeType($name);

is_subclass_of() expects exactly 2 parameters, 3 given in

I keep on getting this error:

is_subclass_of() expects exactly 2 parameters, 3 given in <b>/Applications/MAMP/htdocs/ZF2/try2/vendor/rwoverdijk/assetmanager/src/AssetManager/Service/AssetFilterManager.php</b> on line <b>133</b><br />

So when I edit the file and remove the first param from it I get:

<b>Fatal error</b>:  Class 'JSMin' not found in <b>/Applications/MAMP/htdocs/ZF2/try2/vendor/kriswallsmith/assetic/src/Assetic/Filter/JSMinFilter.php</b> on line <b>32</b><br />

hope you guys can help me out with this.

Extension-based filters not working as expected

This doesn't work:

// Asset manager.
'asset_manager' => array(
    'resolver_configs' => array(
        'paths' => array(
            __DIR__ . '/../public'
        )
    ),
    'filters' => array(
        'less' => array(
            array('filter' => 'Lessphp')
        )
    )
)

This does:

// Asset manager.
'asset_manager' => array(
    'resolver_configs' => array(
        'paths' => array(
            __DIR__ . '/../public'
        )
    ),
    'filters' => array(
        'assets/app/styles/app.less' => array(
            array('filter' => 'Lessphp')
        )
    )
)

Am I misunderstanding how extension-based filters work?

Commit fcb45e50a310a0297d8c42334d2fa84d7a51606a breaks AssetManager

Hi guys,

After the update to 1.4.0 today, we are expecting an error being raised by ZF2: Fatal error:
Uncaught exception 'Zend\ServiceManager\Exception\ServiceNotFoundException' with message 'Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for AssetManager\Service\MimeResolver' in /var/www/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 529

After some investigation, it would seem that the naming change in the commit fcb45e5 (invokables config) could be the cause of it, as that's the commit it stops working for us.

Cheers,
Martin

Resolvers could use Assetic's AssetInterface in `resolve` result

Assetic provides a generic AssetInterface, which is quite flexible and allows us to apply existing Assetic filters/caches.

I'm hereby suggesting to change the interface to following:

<?php

namespace AssetManager\Resolver;

interface ResolverInterface
{
    /**
     * Resolve a given file name to a system path
     *
     * @param string $path
     * @return \Assetic\Asset\AssetInterface|null the absolute path to the file
     */
    public function resolve($path);
}

This allows us to have a single asset pointing either to a glob path or a file or a directory or a string. That gives us the freedom to have the Assetic filtering/caching.

To keep the current behavior, it should be enough to use a FileAsset pointing to what currently is our string. The collection resolver can instead resolve to an AssetCollection. This would also not break our public api.

kriswallsmith/assetic dependency

Right after installing your module I found no ApcCache in kriswallsmith/assetic package. So I specified dev-master version instead of * in my own application composer.json and updated dependencies then I was able to use ApcCache;
It's hard to say what exact version of kriswallsmith/assetic package was downloaded initially but I guess it's better to refer to dev-master in rwoverdijk/assetmanager/composer.json.

Issue with SlmLocale and AssetManager

AssetManager acts on 404 after routing. SlmLocale's UriPathStrategy does redirecting before routing...

This seems to conflict as SlmLocale redirects an /css/style.css request to /[locale]/css/style.css, modifies the router's baseUrl (not the request)

ocramius mentioned he knew what to do
(I was lost very early in that discussion, so hope still remembers when he gets around to this... ;-) )

Why does the Apc cache still do a lot of resolving?

I have a collection "admin/js/vendor.js" with a lot of vendors combined (jquery, jquery UI, etc). I would like to cache these files in APC because they almost never change. When they does I will clear the APC cache manually.

But when I use xdebug I see that with APC still all the resolving happens. I'm using Vagrant (VM with a shared folder to my host machine) and want to avoid all these slow disk lookups.

Is it possible to check for the path "admin/js/vendor.js" directly in APC and return the content?

filter applied twice on assets in collection

AssetManager\Resolver\Collection\Resolver::resolve is going through assets in collection and apply filters to each asset using the AssetFilterManager

The colection itself is also an implementation of AssetInterface and get the same fitler applied. The collection is then going through its assets and apply the filters again, so for example if you added filters, the method loadFilter or dumpFilter (in Assetic\Filter\FilterInterface) is invoked twice for each asset.

Allow keys for paths

A nice addition would be to allow a starting alias for the paths. So the following:

array(
    'mymodule' => __DIR__ . '/../public',
);

Would resolve the following url:
http://example.com/mymodule/js/example.js

to: /../public/js/example.js

basically trimming off the key.

Additional FAQs needed

Need to add FAQs somewhere for:

  1. The fact that asset manager acts only on 404s, so controllers/routes should be acting according to that. If a controller causes 5xx errors, we're not to be blamed for assets not being served.
  2. The fact that assets should be namespaced (reads: different base path) to make collisions harder. Up to the consumer of AssetManager.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.