Linking to CSS, JS and Images in Laravel

blank (1)
For linking to the CSS, Javascript and images files, we need to install a package and package name is LavavelCollective.

Open your system terminal and browse to the laravel project folder.

Package will be installed using the composer and we need to run below command on the terminal.

After run above command the package will be install into our laravel project.

For verify that the package is installed in our system, you need to open composer.json file in your project and you will see the entry of that package into the file.

After installing and verify the package into our package, we need to make available package into our project.

Open your config/app.php file and add new provider into your providers array.

and after that we will use 2 class aliases into aliases array in the same config/app.php file.

Now save and close the config/app.php file.

Now the package is available to use into our project.

Now open /resources/views folder and open any blade template file.

For linking the css file into your template:

Above code will produce the following HTML output:

For linking the javascript file into your template:

Above code will produce the following HTML output:

For linking the image file into your template:

Above code will produce the following HTML output:

Note: I am assume that these css,js and images files are already in the public folder.
Like bootstrap.min.css file in /var/www/html/laravel/public/css/bootstrap.min.css,
bootstrap.min.js in the /var/www/html/laravel/public/css/bootstrap.min.js
and agency.jpg in /var/www/html/laravel/public/img/agency.jpg.

Leave a Comment

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

Optimization WordPress Plugins & Solutions by W3 EDGE