I am a beginner with Symfony and I am trying to integrate a specific Bootstrap theme and jQuery.
Because of the css files, the js files and the fonts are shared by all the bundles, I put the resources into the app\Resources\public directory.
In this directory, I have the following architecture :
- css
- bootstrap.min.css
- jquery-ui.min.css
- my-css.min.css
- fonts
- glyphicons-halflings-regular.eot
- glyphicons-halflings-regular.svg
- glyphicons-halflings-regular.ttf
- glyphicons-halflings-regular.woff
- js
- bootstrap.min.js
- jquery-1.9.1.min.js
I also have a layout.html.twig file in the app\Resources\views directory which is my main layout. In this layout, I load the css and the js files with the following twig blocks :
<!-- CSS -->
{% block stylesheets %}
{% stylesheets filter='cssrewrite'
'../app/Resources/public/css/bootstrap.min.css'
'../app/Resources/public/css/jquery-ui.min.css'
'../app/Resources/public/css/my-css.min.css'
%}
<link href="{{ asset_url }}" rel="stylesheet" media="screen">
{% endstylesheets %}
{% endblock %}
<!-- JS -->
{% block JavaScript %}
{% javascripts
'../app/Resources/public/js/jquery-1.9.1.min.js'
'../app/Resources/public/js/bootstrap.min.js'
%}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
{% endblock %}
The CSS files are correctly loaded in my pages, but I have an error when I use glyphicon. The icons, on a button for example, are not loaded and in the console of Firefox, I have an error 403 :
GET
http://localhost/mylibrary-web/app/Resources/public/fonts/glyphicons-halflings-regular.woff [HTTP/1.1 403 Forbidden 4ms]
I try to modify the security.yml file without success :
firewalls:
dev:
pattern: ^/(_(profiler|wdt|error)|css|images|js|fonts)/
security: false
How can I authorize the access to the fonts directory ? Thx for your help !
@AcmeBarBundle/Resources/public/js/form.jsor use the path that starts from your web folder:'bundles/app/css/*'Pay attention to your URL, it should not lead to /app/ at all! Take a look at the documentation symfony.com/doc/current/cookbook/assetic/asset_management.html - Artamielappdirectory event if they are globals to the app and not specific to a bundle ? I should put the resources into a bundle or directly into thewebfolder ? That's right ? - rolandlwebfolder to be accessed properly. Otherwise, you can use your bundleResourcesfolder and simply use the option--symlinkfor generating assets. - Artamiel