PHP code example of thecoderraman / laravel-assets-version

1. Go to this page and download the library: Download thecoderraman/laravel-assets-version 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/ */

    

thecoderraman / laravel-assets-version example snippets


# For Type Js
js_path('app.js');  // "assets/js/app.js?3085ede8f2"

# For Type Css
css_path('app.css');  // "assets/css/app.css?3ede8f2085"

# For Other Types
asset_path('images/logo.png');  // "assets/images/logo.png?e8f203ed85"

<link href="{{ asset_path('js/app.js') }}" rel="stylesheet">



namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use TheCoderRaman\AssetsVersion\Support\Facades\AssetsVersion;

class WelcomeController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return string
     */
    public function index()
    {
        // "assets/js/app.js?3085ede8f2"
        dump(AssetsVersion::jsPath('app.js'));

        // "assets/css/app.css?3ede8f2085"
        dump(AssetsVersion::cssPath('app.css'));

        // "assets/images/logo.png?e8f203ed85"
        dump(AssetsVersion::assetPath('images/logo.png'));
    }
}
bash
$ php artisan vendor:publish --tag=assets-version
bash
edit: config/assets-version.php
bash
# For generating assets version cache file
$ php artisan assets-version:cache

# For removing assets version cached file
$ php artisan assets-version:clear