An ultra-simple-to-use assets management library for PHP
Hi, i really love your package but i have several problem. In some case i need to load assets but except autoload and some other assets. Lets say in default layout i will load all the autoloaded assets but in the ajax layout i will only need to load added assets without the autoloaded. Can i load assets like that ?
@carrpirates yes you can. In your AJAX controller you can call Assets::reset() and all the autoloaded (or any other loaded) assets will be reset. If you need to reset only CSS assets you can call Assets::resetCss() and if you need to reset only JS you can call Assets::resetJs()
My master layout depend on the request, so my master layout taking control which master layout should be used. I don't have ajax controller. All controller can serve both ajax and http request. I think i need some method like Assets::js(['autoload' => false]) since autoload is not collection and sometimes its not necessary to load them.
Then I think your best option is not to use autoload at all. Save all assets that are currently in the autoload as a collection and use that collection when needed
anyone here for a quick question?
using this package for the first time and I am wondering if there is a way to"order" the assets being outputted when adding ?
IE add a JS file but require another JS file be added first?
@ninjaparade I-m afraid there is no way to choose the order the assets are outputted. Assets are always loaded in the same order the where added. For collections the are loaded in the same order they are defined.
So if you want to require a JS file (A) before loading another file (B), you could create a collection including the dependency file first (A) and the dependant file then (B) and just load the collection
This message was deleted
@Stolz that's actually not what I was trying to do, let me explain a little better.
I have a master layout, that I have a core group of assets that are needed for my app, and then on PER page load, some pages (sections) require more assets, scripts etc.
so when I try to append to that collection that my master layout is using, the newly added script comes before the collection I created
@ninjaparade It is tecnically imposible to add an asset before another. Take a look at the code and see how assets are ultimately added:
$this->css = $asset;
$this->js = $asset;
So what I think is happening is that your routed code is not been actually executed in the order you think it is. This can easily happen if you load your assets using layout managers (such Laravel Blade), middlewares or view composers . You need to fully understand the life cycle of a request in your framework/app to debug what is that happening.
I've been using a homegrown PHP-based asset manager, but it is pretty limited
and lately I've been checking out npm and Gulp, but there are a couple missing features (like stream wrappers) that I'm getting hung up on
If you are looking for a feature-rich assets library I'm afraid Stolz/Assets is not for you. The goal of the library is to be as simple and easy to use as possible. For instance, It lacks assets compilation or assets preprocessing features.
oh! are you familiar with Grav?
apparently their asset manager is adapted from Stolz/Assets
I'm not familiar with Grav but I'm glad they found my work useful ;)
hey, i want to ask, Can we upload the aggregated version to AWS S3 directly?
using font-awesome, it wants woff files. Can we load those too?
@chalamministries , as far as I know you can't load woff files directly in your HTML. They are meant to be loaded from within a css file via @font-face. That means that even if you use the assets library to load them directly in your HTML it won't work.
If FontAwesome is already using @font-face and you are using the pipelone, you may need to update the path of the font in the original CSS files
@Stolz does the package provide asset dependency feature
@marwankhanfar_twitter yes it does, sort of. If any of the assets you add matches the name of a collection, all the assets of that collection will be added. If any of the assets of that collection happens to match the name of another collection, then all assets on that second collection will be loaded, and so on and so forth
so by referencing collections you can load dependent nested collections
@bk9999 Are you using Laravel or not?. 'Assets' is the name of the Laravel facade. If you are not using Laravel you need to use the full class name which is 'Stolz\Assets\Manager'
i have a problem with this package, how to give version on js and css file ? thanks
@andirohandi_gitlab To specify a version you must set the pipeline option value to the value of your version, for instance 'pipeline' => '1.0'. If you set 'pipeline' => 'auto' the version will be automatically calculated based on your assets last modification time.