Wallogit.com
2017 © Pedro Pelรกez
Asset management for aura v2
Asset management for PHP., (*1)
This package requires PHP 5.3 or later. Unlike Aura library packages, this asset package has userland dependencies:, (*2)
This asset-bundle is installable and autoloadable via Composer with the following
require element in your composer.json file:, (*3)
"require": {
"aura/asset-bundle": "2.*"
}
composer install phpunit -c tests/unit
This kernel attempts to comply with PSR-1, PSR-2, and PSR-4. If you notice compliance oversights, please send a patch via pull request., (*5)
To ask questions, provide feedback, or otherwise communicate with the Aura community, please join our Google Group, follow @auraphp on Twitter, or chat with us on #auraphp on Freenode., (*6)
Assume you have a Vendor.Package. All your assets should be in the
web folder. The folder names css, images, js can be according to your preffered name., (*7)
โโโ src
โย ย โโโ Cli
โย ย โโโ Web
โโโ tests
โโโ web
โโโ css
โย ย โโโ some.css
โโโ images
โย ย โโโ another.jpg
โย ย โโโ some.png
โโโ js
โโโ hello.js
Assuming you have the same structure, now in your template you can point
to /asset/vendor/package/css/some.css, /asset/vendor/package/js/hello.js, /asset/vendor/package/images/another.jpg., (*8)
Onething you still need to make sure in the name asset/vendor/package, (*9)
vendor/packagewhich is the composer package name., (*10)
Add path to the router, according to the router you are using so that vendor, package and file name can be extracted from it., (*11)
An example of usage with Aura.Router and Aura.Dispatcher is given below. The dispacther is used for it need to recursively call the __invoke method. Else action will return responder, then you need to invoke responder to get the response and finally do send the response., (*12)
'/path/to/web/where/css/js/etc/',
'my/package2' => '/path/to/web/where/css/js/etc/of/packag2'
);
$types = array();
$router->add('aura.asset', '/asset/{vendor}/{package}/{file}')
->setValues([
'action' => 'aura.asset',
])
->addTokens(array(
'file' => '(.*)'
));
$dispatcher->setObject(
'aura.asset',
function () use ($map, $types) {
$action = new \Aura\Asset_Bundle\AssetAction(
new \Aura\Asset_Bundle\AssetService($map, $types),
new \Aura\Asset_Bundle\AssetResponder()
);
return $action;
}
);
```
In your layout or view
```php
```
## Usage in Aura.Web_Kernel
```php
params['Aura\Asset_Bundle\AssetService']['map']['cocoframework/example'] = dirname(__DIR__) . '/web';
}
```
Make sure you have router helper defined for Aura.View.
```php