PHP code example of aura / asset-bundle

1. Go to this page and download the library: Download aura/asset-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aura / asset-bundle example snippets



$map = array(
    'my/package' => '/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;
    }
);

<link href="/asset/<vendor>/<package>/css/bootstrap.min.css" rel="stylesheet">


    // more code
    public function define(Container $di)
    {
        $di->params['Aura\Asset_Bundle\AssetService']['map']['cocoframework/example'] = dirname(__DIR__) . '/web';
    }

<link rel="stylesheet" href=" echo $this->router()
      ->generateRaw('aura.asset',
          array(
              'vendor' => 'cocoframework',
              'package' => 'example',
              'file' => '/css/syntax.css'
          )
      );