1. Go to this page and download the library: Download josantonius/asset 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/ */
use Josantonius\Asset\Elements\Link;
new Link(
crossorigin: 'anonymous',
href: 'https://example.com/style.css',
integrity: 'sha256-n9+',
media: 'all',
rel: 'stylesheet'
);
use Josantonius\Asset\Facades\Asset;
Asset::addLink(
href: 'https://example.com/style.css',
rel: 'stylesheet'
);
use Josantonius\Asset\Asset;
$asset = new Asset();
echo $asset->outputBodyScripts();
use Josantonius\Asset\Facades\Asset;
echo Asset::outputBodyScripts();
use Josantonius\Asset\Asset;
$asset = new Asset();
echo $asset->outputHeadScripts();
use Josantonius\Asset\Facades\Asset;
echo Asset::outputHeadScripts();
use Josantonius\Asset\Asset;
$asset = new Asset();
echo $asset->outputLinks();
use Josantonius\Asset\Facades\Asset;
echo Asset::outputLinks();
use Josantonius\Asset\Elements\Link;
use Josantonius\Asset\Elements\BodyScript;
use Josantonius\Asset\Elements\HeadScript;
new BodyScript(src: 'foo.js', async: true);
new BodyScript(src: 'bar.js', type: 'text/javascript');
new HeadScript(src: 'https://example.com/foo.js', type: 'module');
new HeadScript(src: 'https://example.com/bar.js', defer: true);
new Link(href: 'https://example.com/foo.css', rel: 'stylesheet');
new Link(href: 'https://example.com/bar.css', rel: 'stylesheet', media: 'all');