PHP code example of lapaz / amechan
1. Go to this page and download the library: Download lapaz/amechan 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/ */
lapaz / amechan example snippets
$assetManager = new AssetManager();
$assetManagr->asset('jquery', [
'file' => '/assets/vendor/jquery/dist/jquery.js',
'section' => 'js',
]);
$assetManagr->asset('bootstrap', [
'baseUrl' => '/assets/vendor/bootstrap/dist',
'bundles' => [
[
'files' => ['css/bootstrap.css', 'css/bootstrap-theme.css'],
'section' => 'css',
],
[
'file' => 'js/bootstrap.js',
'section' => 'js',
],
],
'dependency' => 'jquery',
]);
$assetManagr->asset('some-jquery-plugin', [ ... ]);
$assetManagr->asset('and-another-one', [ ... ]);
$assets = $assetManagr->newCollection();
$assets->add('bootstrap');
$assets->add('bootstrap');
$assets->add('some-jquery-plugin');
foreach ($assets->collectUrls('css') as $url) {
echo "<link href="{$url}" rel="stylesheet">\n";
}
foreach ($assets->collectUrls('js') as $url) {
echo "<script src="{$url}"></script>\n";
}
if (is_dir(__DIR__ . '/../public/assets/dist')) {
$assetManager->mapping(new UnifiedResourceMapper('/assets', [
'dist/css/all.min.css' => [
'vendor/bootstrap/dist/css/bootstrap.css',
'vendor/bootstrap/dist/css/bootstrap-theme.css',
],
'dist/js/all.min.js' => [
'vendor/jquery/dist/jquery.js',
'vendor/bootstrap/dist/js/bootstrap.js',
],
]));
}
if (is_file(__DIR__ . '/../public/assets/dist/rev-manifest.json')) {
$manifest = json_decode(file_get_contents(
__DIR__ . '/../public/assets/dist/rev-manifest.json'
), true);
$assetManager->mapping(new RevisionHashMapper('/assets/dist/', $manifest));
}