Laravel Router Not Allowing Javascript Files - laravel

I'm having a really crazy issue and I can't seem to figure it out. I've got an app that was working perfectly fine in Laravel 5.2, and I've since upgraded to Laravel 5.3. When I serve the standard view from routes/web.php and include a script tag, Laravel is trying to load the script tag as a route instead of including the file. Example:
If I add the folowing:
<script src="/js/lib/jquery.min.js"></script>
At the end of my welcome.blade.php (or index, or any of them really), I get the following in the console:
Console Error
And if I look into Sources in the Chrome devtools at the jquery file, it's loaded my same blade file as the JS file (like Laravel is trying to load it via the router). Does anyone have any hints on where I can look? I really don't want to go through the process of trying to reinstall or back out the an earlier version.
EDIT: To clarify, I've been working on this a bit, and it turns out that the app.js file will load just fine, but the js/lib/**.js files won't. I don't really know what the difference is.

How about that syntax?
<script type="text/javascript" src="{{ URL::asset('/js/lib/jquery.min.js') }}"></script>
Hope it helps you :)

That only happens when the file is not found. Check the file name again, the path and also remember pathname may be case sensitive.

Related

laravel not picking file through asset()

In my laravel project i am trying to get js file though asset('js/app.js') which is inside public folder. it is working fine on localhost but on server it is not picking file. It is working on another server. I think there is any issue with htaccess file.
I try to use url() and URL::asset() but not working. I checked source of page link is perfect but still fail to pick file
I want to access that js file.
The question has been answered in the comments, and was solved with this code:
asset('public/js/app.js')

Laravel - how to access public folder from JS file

I am using the exact same Ajax call in multiple blade templates.
If Ajax fails, I show an error jpg located in public/images/danger.png.
When I had my JS in the blade file written inline in <script> tags, it was easily accessible as I had blade helpers to access public with:
{{asset('/images/danger.png')}}
Yet now, accessing /public with:
http://"+location.host +"/public/images/danger.png
is impossible.
It would be unDRY to put the exact same AJAX call in 12 blades, no need to elaborate why..
How do you guys counter this issue?
remove /public from your route,you can directly use /images/imgname.jpg
You can just use absolute routes in your javascript files. This will however not work if your Laravel application sits in a sub folder.
"/public/images/danger.png"
just the same as used in html (in blade)
like
$('.abc').attr("src", "{{asset('imgs/male_b.svg')}}");

Laravel File Manager dosn't load css, js files

I integrated Laravel File Manager in my laravel project and at first it worked properly, but after I remove public [ I followed this instruction remvove public from url ] from url it din't work anymore. The css file is missing and browse file also din't work. I tried to include those files**[css, js]** into head section also din't work. It still show like this
I have no idea how to fix this error. Can anyone help me please?

Laravel Blade engine does not work properly

i already uploaded my laravel 5.5 app on my host.
my problem is when i try to use
#extends('layouts.app')
#section('content')
///
#endsection
in my views, HTML works fine but blade template doesn't work.
also when I check source code with the browser I find that the "#" mark doesn't exist.
my browser source code :
extends('layouts.app')
section('content')
///
endsection
Help me ! :)
In order to work with Blade engine, make sure your view named with .blade.php extension just like Cy Rossignol mentioned in the comment. Example : home.blade.php. You can read the docs here

Symfony - Assets cache auto versioning

I'd like to force client's cache refresh for modified assets.
Is there already a native way to do it with asset() like
<script src="{{ asset('js/main.js')|autoversion }}"></script>
?
If not, I found this really elegant solution (based on file timestamp & url rewrite) to manage it.
Did someone already faced this question and would know how to extend asset() for example?
Take a look at the assets_version parameter, so every asset get a version string without doing extra things in the template
You can try it, i'm not sure of the result but it can work.
php app/console assetic:dump --watch

Resources