Bonjour à tous,
J'ai un souci depuis deux jours, que je n'arrive pas à régler et qui se situe au niveau de mes assets. En effet, j'ai une page HTML (en TWIG) à laqulle je veux rattacher mon fichier CSS... Chose toute basique, mais je ne m'en sors plus avec ces assets, le chemin est bien reconnu, mais lorsque je lance mon appli, j'ai un joli message : GET http://localhost:8000/css/style.css net::ERR_ABORTED
Je précise que j'utilise PHPStorm (je ne sais pas si ça peut avoir une incidence), que je lance mon application en local via la commande php bin/console server:run.
Mon fichier CSS est localisé à la racine de mon projets => /assets/css/style.css
La page HTML de référence TWIG:
La page que je souhaite afficher (la route est bonne, j'ai bien mon titre qui s'affiche):
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>{% block title %}Page d'accueil{% endblock %}</title> {% block stylesheets %} <link type = "text/css" rel="stylesheet" href="{{ asset('css/style.css') }}" /> {% endblock %} </head> <body> {% block body %}{% endblock %} {% block javascripts %}{% endblock %} </body> </html>
Mon composer :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 {% extends 'base.html.twig' %} {#{% block stylesheets %}#} {#<style>#} {##map#} {#{#} {#height: 750px;#} {#position: relative;#} {#}#} {#</style>#} {#{% endblock %}#} {% block body %} <h3>Accueil</h3> <div id="map"></div> <script> function initMap() { var map = new google.maps.Map(document.getElementById('map'), { center: {lat: -34.397, lng: 150.644}, zoom: 6 }); var infoWindow = new google.maps.InfoWindow({map: map}); // Try HTML5 geolocation. if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { var pos = { lat: position.coords.latitude, lng: position.coords.longitude }; infoWindow.setPosition(pos); infoWindow.setContent('<style>p{color: red;}</style><p>Hello !! :)</p>'); map.setCenter(pos); }, function() { handleLocationError(true, infoWindow, map.getCenter()); }); } else { // Browser doesn't support Geolocation handleLocationError(false, infoWindow, map.getCenter()); } } function handleLocationError(browserHasGeolocation, infoWindow, pos) { infoWindow.setPosition(pos); infoWindow.setContent(browserHasGeolocation ? 'Error: The Geolocation service failed.' : 'Error: Your browser doesn\'t support geolocation.'); } </script> <script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBluRZPBnIrqrFRpb0vw6_BabF-mOKc6ns&callback=initMap"> </script> {% endblock %}
Merci d'avance si quelqu'un trouve la solution, je m'en arrache les cheveux :p
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85 { "type": "project", "license": "proprietary", "require": { "php": "^7.1.3", "ext-iconv": "*", "doctrine/doctrine-bundle": "^1.8", "easycorp/easyadmin-bundle": "^1.17", "sensio/framework-extra-bundle": "^5.1", "symfony/asset": "^4.0", "symfony/console": "^4.0", "symfony/debug-pack": "*", "symfony/expression-language": "^4.0", "symfony/flex": "^1.0", "symfony/form": "^4.0", "symfony/framework-bundle": "^4.0", "symfony/lts": "^4@dev", "symfony/maker-bundle": "^1.3", "symfony/monolog-bundle": "^3.1", "symfony/orm-pack": "^1.0", "symfony/process": "^4.0", "symfony/security-bundle": "^4.0", "symfony/serializer-pack": "*", "symfony/swiftmailer-bundle": "^3.1", "symfony/translation": "^4.0", "symfony/twig-bridge": "^4.0", "symfony/validator": "^4.0", "symfony/web-link": "^4.0", "symfony/web-server-bundle": "^4.0", "symfony/webpack-encore-pack": "*", "symfony/yaml": "^4.0" }, "require-dev": { "doctrine/doctrine-fixtures-bundle": "^3.0", "symfony/browser-kit": "^4.0", "symfony/css-selector": "^4.0", "symfony/dotenv": "^4.0", "symfony/phpunit-bridge": "^4.0", "symfony/profiler-pack": "*" }, "config": { "preferred-install": { "*": "dist" }, "sort-packages": true }, "autoload": { "psr-4": { "App\\": "src/" } }, "autoload-dev": { "psr-4": { "App\\Tests\\": "tests/" } }, "replace": { "symfony/polyfill-iconv": "*", "symfony/polyfill-php71": "*", "symfony/polyfill-php70": "*", "symfony/polyfill-php56": "*" }, "scripts": { "auto-scripts": { "cache:clear": "symfony-cmd", "assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd" }, "post-install-cmd": [ "@auto-scripts" ], "post-update-cmd": [ "@auto-scripts" ] }, "conflict": { "symfony/symfony": "*" }, "extra": { "symfony": { "id": "01C91V53VM493PCRW7GSQRFNKZ", "allow-contrib": false } } }
Partager