Laravel Asset Management |
X

Congrats, You are Subscribed to Receive Updates.

Laravel Asset Management


Laravel Asset Management is the custom and necessary things to add your Custom CSSĀ and JS files into the Laravel Working Area. We are going to discuss about the ways to add Assets into it. In laravel 3, you can use the Asset method to add styles and javascripts into it.

asset-managemenrt-laravel

Just use the following line of codes.

Asset::add('kv_js', 'js/kv_js.js');

Here it accepts two parameters,

1. Name of the assets, given by our own convinence,

2. files location under public directory.

It will collect the informations with help of file extension, either js or css file. But we need to use dump method to use these assets on live.

<head>
    <?php echo Asset::styles(); ?>
    <?php echo Asset::scripts(); ?>
</head>

Just simple to add the Custom Assets into it. If you are using Laravel 4, Than you can use the following trick to add your assets into it.

Assets::add('filename.extension');

This is also similar to the existing method. You can add array of Assets into it.

Assets::add(array('kv/kv_js.js', 'kv/kv_css.css'));

Likewise you can add many with it. Not only the localy hosted files, also you can add the CDN host files too.

Assets::add('//cdn.example.com/jquery.js'));

And in your view files, just add the following functions to get the list of Assets which are updated with it.

echo Assets::css();

echo Assets::js();

And another way is also available. You can simply add files separately like the following one.

After Laravel 4, you can use the following method to add Assets into it.

{{ HTML::style('css/kv_css.css') }}

{{ HTML::style('js/kv_js.css') }}

That’s it to play with assets .

commenter

About Varadharaj V

The founder of Kvcodes, Varadharaj V is an ERP Analyst and a Web developer specializing in WordPress(WP), WP Theme development, WP Plugin development, Frontaccounting(FA), Sales, Purchases, Inventory, Ledgers, Payroll & HRM, CRM, FA Core Customization, PHP and Data Analyst. Database Management Advance Level

2 comments

  1. commenter

    Laravel 4 doesn’t have Asset class so you can’t use Asset::

Reply to Varadharaj V Cancel reply

Your email address will not be published. Required fields are marked *

*

Current ye@r *

Menu

Sidebar