PHP code example of mediactive-digital / laravel-asset-aliases

1. Go to this page and download the library: Download mediactive-digital/laravel-asset-aliases 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/ */

    

mediactive-digital / laravel-asset-aliases example snippets


'providers' => [
    // ...
	MediactiveDigital\LaravelAssetAliases\LaravelAssetAliasesServiceProvider::class,
],

'aliases' => [
    // ...
    'MDAsset' => MediactiveDigital\LaravelAssetAliases\LaravelAssetAliasesFacade::class,
],

// Example
return [
	'css' => [
		'stylesheet' => 'stylesheet.css'
	],
	'js' => [
		'script' => 'script.js'
	]
];

// Examples

// Inside configuration file : 
return [
	'css' => [
		'stylesheet' => [
			'file' => 'stylesheet.css',
			'attributes' => [
				'media' => 'print',
				'title' => 'title'
			]
		],
		'other-stylesheet' => [
			'file' => 'other-stylesheet.css',
			'attributes' => [
				'media' => 'screen'
			]
		]
	],
	'js' => [
		'script' => [
			'file' => 'script.js',
			'attributes' => [
				'integrity' => 'sha384-rAnDoMkeY',
        		'crossorigin' => 'anonymous'
			]
		],
		'other-script' => [
			'file' => 'other-script.js',
			'attributes' => [
				'async' => null
			]
		]
	]
];

// Inside Blade template : 
{!! MDAsset::addCss([
	[
		'file' => 'stylesheet', 
		'attributes' => [
			'media' => 'print',
			'title' => 'title'
		]
	], 
	[
		'file' => 'other-stylesheet', 
		'attributes' => [
			'media' => 'screen'
		]
	]
]) !!}

{!! MDAsset::addJs([
	[
		'file' => 'script.js', 
		'attributes' => [
			'integrity' => 'sha384-rAnDoMkeY', 
			'crossorigin' => 'anonymous'
		]
	], 
	'other-script' => [
		'file' => 'other-script.js',
		'attributes' => [
			'async' => null
		]
	]
]) !!}

	{!! MDAsset::addJs('script.js') !!}

	{!! MDAsset::addJs(['script.js', 'script2.js']) !!}