Download the PHP package nathanburkett/ecosystem without Composer
On this page you can find all versions of the php package nathanburkett/ecosystem. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nathanburkett/ecosystem
More information about nathanburkett/ecosystem
Files in nathanburkett/ecosystem
Informations about the package ecosystem
NathanBurkett/Ecosystem
Ecosystem is a simple and smart environment manager for your user-facing scripts and stylesheets.
Ecosystems are useful when you have collections of separate resources for differing sections of your application - http://example.com vs. http://example.com/admin. Creating an Ecosystem for each section allows to you manage each's resources in a collection one place while being able to add new resources to the collection on the fly.
Install
To install Ecosystem as a Composer package, run:
Once it's installed, you can register the service provider in config/app.php
in the providers
array:
And register the Ecosystem
facade in the the aliases
array:
Then publish Ecosystems's assets with php artisan vendor:publish
. This will add the file config/ecosystem.php
. This config file allows certain envionments to disable cache-busting strings.
Usage
Creating a New Ecosystem
Run php artisan
from the console, and you'll see the new make:ecosystem
command.
Running php artisan make:ecosystem StandardEcosystem
from the console will create StandardEcosystem
in App\Library\Ecosystems
directory. If directory doesn't exist, the command will create it.
To place Ecosystem in a different directory, append --namespace=Your\Namespace\Here
to the command. Doing so will create an Ecosystem in the string of directories starting with a lowercase version of the first directory segment - ie --namespace=Resources\Ecosystems
would place the Ecosystem in resources\Ecosystems
.
The command php artisan make:ecosystem StandardEcosystem
would generate the following file in the App\Library\Ecosystems
directory.
Adding assets to any of the default
collections allows you to display them easily from any view.
This will bundle the assets in a Laravel Collection until they're output in a view. In a view associated with this route
Would output
Attaching to Routes
Ecosystems are assigned to routes and groups of routes by attaching them as middleware.
Ecosystems are overridden so the most immediate one on the route is used
Dynamically Attaching Assets
Because the assets are not compiled and output until runtime, you have the ability to add one-offs to the Collection. This is typically done in a Controller.
Would change the Ecosystem::getHeadScripts()
output to
The Ecosystem::addScriptToHead()
, Ecosystem::addStylesheet()
, Ecosystem::addScriptToFooter()
take a maximum of three arguments. A name for the asset, an array of attributes for the asset, and a option to set the asset before one already added to the Collection.
Supplying the name of an already registered asset in the $before
argument will push the new asset above the target.
Yields
Available Methods
The Ecosystem facade
exposes certain methods to interact with the current Ecosystem while the actions fall within a route which has an Ecosystem registered to it.
These three methods output any assets registered to its collection in html elements and are intended to be used in views
:
Ecosystem
lets you add one-off assets in any area that the route middleware attached Ecosystem covers. However, this is typically done in Controllers.
Change log
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONDUCT for details.
Security
If you discover any security related issues, please email instead of using the issue tracker.
Credits
- Nathan Burkett
- All Contributors
License
The MIT License (MIT). Please see License File for more information.