Where should static javascript and css files in a Laravel 4 application. For the sake of my own understanding, I'm not interested in using any sort of assets or packages yet.
I tried putting them under public/js
and public/packages
to no avail, getting the following 404 errors in my page:
GET http://localhost/~myuser/mytest/packages/test2.js 404 (Not Found)
GET http://localhost/~myuser/mytest/js/mytest.js 404 (Not Found)
Here is what my .htaccess
file looks like for reference:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /~myuser/mytest/public/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
All assets should be placed in the public
folder
public/js
public/css
public/fonts
public/images
You can access the assets using the asset()
method or the Laravel HTML helper methods HTML::script
and HTML::style
.
i.e to include Javascript file:
- <script src="{{ asset('js/yourfile.js') }}"></script>
- {{ HTML::script('js/yourfile.js') }}
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With