I'm trying to figure out how to make this icon font work in the dev environment of Symfony. In production environment, everything works fine. I'm using assetic to manage my assets. I downloaded font-awesome with bower. Here's my code:
config.yml
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ AdminBundle, UserBundle, ShopBundle, SiteBundle ]
filters:
cssrewrite: ~
base.html.twig
{% block stylesheets %}
{% stylesheets
'vendor/bootstrap/dist/css/bootstrap.css'
'vendor/font-awesome/css/font-awesome.min.css'
filter='?cssrewrite'
%}
<link rel="stylesheet" type="text/css" href="{{ asset_url }}" />
{% endstylesheets %}
{% endblock %}
Snippet from rendered html
<html>
<head>
<meta charset="UTF-8">
<title>Admin Area</title>
<link href="/stocksolutions/web/app_dev.php/css/00007d5_bootstrap_1.css" type="text/css" rel="stylesheet">
<link href="/stocksolutions/web/app_dev.php/css/00007d5_font-awesome.min_2.css" type="text/css" rel="stylesheet">
<link href="/stocksolutions/web/app_dev.php/css/b4f457d_part_1_admin_1.css" type="text/css" rel="stylesheet">
<link href="/stocksolutions/web/favicon.ico" type="image/x-icon" rel="icon">
</head>
<body>
(...)
<script src="/stocksolutions/web/app_dev.php/js/ddd7e15_jquery.min_1.js" type="text/javascript"></script>
<script src="/stocksolutions/web/app_dev.php/js/ddd7e15_bootstrap.min_2.js" type="text/javascript"></script>
</body>
</html>
font-awesome css-file
@font-face {
font-family: "FontAwesome";
font-style: normal;
font-weight: normal;
src: url("../fonts/fontawesome-webfont.eot?#iefix&v=4.1.0") format("embedded-opentype"), url("../fonts/fontawesome-webfont.woff?v=4.1.0") format("woff"), url("../fonts/fontawesome-webfont.ttf?v=4.1.0") format("truetype"), url("../fonts/fontawesome-webfont.svg?v=4.1.0#fontawesomeregular") format("svg");
}
Directory Structure
- web
--- css
--- fonts
--- js
...
Anyone who can help me with this?
My workaround works both dev and production mode. I have tested it on Symfony ~2 and ~3 too.
Summary
AppBundle/Resources/public/fonts/font-awesome/
bin/console assets:install
, so it will copy this folder under web/bundles/fonts/font-awesome/ in this case. (app/console in older Symfony version)../bundles/app/fonts/font-awesome/
For example:../bundles/app/fonts/font-awesome/fontawesome-webfont.ttf
Details
I'm using less css.
config.yml
snippet from my layout:
snipets from less files:
Hope this helps. If you have questions about this, feel free to ask!