Assets Dependencies reworked

I'm currently working on a re-implementation of Assets Loading and Assets Dependency handling in Koala Framework.

Other solutions existing like Assetic, FuelPhp don't support resolving dependencies. Bower which has support for dependencies works on library level - but we need fine graded support so we don't have to include the whole extjs for example.

I'll show some implementation details in this blog post:

Class Structure

Object Structure

[Source Google Doc]

  • Kwf_Assets_Dependency_Package: starting point, contains ProviderList and Dependency_Dependencies
  • Kwf_Assets_ProviderList: contains list of possible Providers, also resolves dependencies by creating the object tree
  • Kwf_Assets_Provider_Abstract: can resolve dependencies by creating Kwf_Assets_Dependency_Abstract by a dependency name
  • Kwf_Assets_Dependency_Abstract: base class for dependencies
  • Kwf_Assets_Dependency_File_Js/Css/Scss/Printcss: class representing a single dependency file
  • Kwf_Assets_Dependency_Dependencies: has child dependencies, creates tree structure with oder Dependencies and File objects


Typical usage didn't change, see the documentation.

Example how to use a Package directly:

$package = Kwf_Assets_Dependency_Package_Default::getInstance('Frontend');
var_dump($package->getPackageUrls('text/javascript', 'en'));


The new system is also much faster than the old one:

  • the whole system has been tuned for better performance
  • only a single cache containing the compiled file exists
  • compiled scss files are never cleared on clear-cache (that helps a lot for apps heavily using scss)

Future Plans

With the new system adding new features can be done easily:

  • Ext4 Provider which automatically resolves dependencies based on annotations in Ext4 source code
  • Modernizr support for thru dependencies
  • Sourcemaps support for compiled files
  • Load Package on demand only when required
This entry was posted in Koala Framework by Niko Sams. Bookmark the permalink.

Leave a Reply

Your email address will not be published.

Github Activity

nsams commented on pull request koala-framework/kwc-newsletter#5

nsams commented on pull request koala-framework/kwc-newsletter#5
Feb 22, 2018

bitte um abstimmung bin benjamin damit die bundles gleich strukturiert sind

nsams commented on issue koala-framework/koala-framework#736

Feb 20, 2018

Yes, that is the correct fix, ajax requests timeout after 30 seconds by default. Now why the request is that slow is a completely different topic, …

nsams starred ionic-team/stencil

Feb 19, 2018

A simple, reusable web component compiler

TypeScript 2.3k 5 issues need help Updated Feb 19

nsams commented on pull request koala-framework/koala-framework#728

nsams commented on pull request koala-framework/koala-framework#728
Feb 15, 2018

des funktioniert dann nicht mehr

nsams commented on pull request koala-framework/kwc-newsletter#2

nsams commented on pull request koala-framework/kwc-newsletter#2
Feb 15, 2018

bitte da keine leerzeile