I am trying to take a website I am working on and adapt it to use the symfony framework but I am fairly new at web development and have a bunch of questions.
- I am having an extremely difficult time getting all of my resources to load correctly. I am trying to use assetic but no matter what I try I am getting hundreds of 404 not found responses when I load the page. My current directory structure is listed below:
- Symfony
- src
- CS4750
- PhotoChallengeBundle
- Controller
- Resources
- config
- public
- css
- img
- js
- libraries
- LibraryX
- css
- img
- js
- views
The biggest problem I am having right now is with images within the css files. I have tried using
filters:
cssrewrite: ~
but all of the paths are pointing to http://localhost/Symfony/web/Resources/public/img/*
instead of http://localhost/Symfony/web/bundles/cs4750photochallenge/img
I tried first without doing an asset:install web and then with doing so but neither of those seems to make a difference. If anyone you help me work through this that would be awesome.
Another problem I am having is with a css file which imports two additional css files. When the page loads the additional css files also return 404 responses.
What is the difference between asset:install and asset:dump
I am also having one of my js files return a server error 500 but I address it the same as the rest of the js files which seem to work fine.
Any answers to any of the above questions would be much appreciated or links to relevant website / posts. I have been digging around the interwebs for hours and haven't really made any headway. Please let me know if you need me to post and code or describe my project layout in more detail.
More Info:
Example of css files:
/* IMPORTS ------------------------------------------------------------*/
@import url('reset.css');
@import url('styled-elements.css');
/* HACKS ------------------------------------------------------------*/
.clear {
clear: both;
height: 1px;
}
body {
line-height: 1;
color: #51565b;
background: #f1f1f1 url(../img/bg/patterns/noise.png);
font-family: Arial, Helvetica, sans-serif;
font-size: 100%;
}
Config_dev.yml:
imports:
- { resource: config.yml }
framework:
router: { resource: "%kernel.root_dir%/config/routing_dev.yml" }
profiler: { only_exceptions: false }
web_profiler:
toolbar: true
intercept_redirects: false
monolog:
handlers:
main:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: debug
firephp:
type: firephp
level: info
assetic:
use_controller: true
filters:
cssrewrite: ~
Template:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Weekly Photo Challenge</title>
<!-- CSS -->
{% stylesheets
'@CS4750PhotoChallengeBundle/Resources/public/css/*'
'@CS4750PhotoChallengeBundle/Resources/public/libraries/fancybox/css/*'
filter='cssrewrite'
%}
<link rel="stylesheet" type="text/css" media="screen" href="{{ asset_url }}" />
{% endstylesheets %}
<!-- JAVASCRIPT -->
{% javascripts
'@CS4750PhotoChallengeBundle/Resources/public/js/jquery-1.5.1.min.js'
'@CS4750PhotoChallengeBundle/Resources/public/js/*'
'@CS4750PhotoChallengeBundle/Resources/public/js/ajax/*'
'@CS4750PhotoChallengeBundle/Resources/public/libraries/fancybox/js/*'
%}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}