Symfony doesnt find css file.css files not loading images in Symfony2Symfony/Twig: Extending stylesheet block from an extended bundleSymfony assetic cssrewrite image path in app/ResourcesInclude function in Twig template SymfonyCSS image path missing using assetic in symfony2Installed Symfony 3 demo project Not finding css or js filesSymfony 4, include assets from vendor directoryIncluding Assets (CSS, JS) in Symfony 4 / Twig TemplateUnable to include CSS using “asset” functionWebpack - Materialize with Symfony
What's the correct term for a waitress in the Middle Ages?
Should I "tell" my exposition or give it through dialogue?
Payment instructions from HomeAway look fishy to me
How can you travel on a trans-Siberian train when it is fully booked?
Remove sudoers using script
Can a user sell my software (MIT license) without modification?
Will TSA allow me to carry a Continuous Positive Airway Pressure (CPAP)/sleep apnea device?
How is it possible that Gollum speaks Westron?
Trapping Rain Water
How to pass a regex when finding a directory path in bash?
How Can I Tell The Difference Between Unmarked Sugar and Stevia?
Required to check-in in person at international layover airport
Is it recommended against to open-source the code of a webapp?
How to generate random points without duplication?
Why only the fundamental frequency component is said to give useful power?
Pushout commutative diagram
Is it possible to (7 day) schedule sleep time of a hard drive?
How to make a setting relevant?
Do simulator games use a realistic trajectory to get into orbit?
Does the growth of home value benefit from compound interest?
Bent spoke design wheels — feasible?
How were concentration and extermination camp guards recruited?
Why don't B747s start takeoffs with full throttle?
PostgreSQL - Array of overlapping Polygon Ids
Symfony doesnt find css file
.css files not loading images in Symfony2Symfony/Twig: Extending stylesheet block from an extended bundleSymfony assetic cssrewrite image path in app/ResourcesInclude function in Twig template SymfonyCSS image path missing using assetic in symfony2Installed Symfony 3 demo project Not finding css or js filesSymfony 4, include assets from vendor directoryIncluding Assets (CSS, JS) in Symfony 4 / Twig TemplateUnable to include CSS using “asset” functionWebpack - Materialize with Symfony
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I've just done a fresh install of the latest Symfony version. Inside my templates
folder I've created a new folder called website which contains a base.html.twig
and a home.html.twig
.
File structure: templates/website/base.html.twig
Inside my public
directory I've created the following css/app.css
. Now in my base I've done:
<link rel="stylesheet" href=" asset('css/app.css') " type="text/css">
Inside my stylesheet I'm just setting the body background colour to red so I know it works. For whatever reason it isn't loading my css. When I view source it appears as:
<link rel="stylesheet" href="/css/app.css" type="text/css">
and clicking the href I just get a Symfony 404. I cannot figure out why it isn't loading my static CSS file.
I don't want to use Symfony Encore as thats overcomplicating things for my project. I have also tried assets:install
command and nothing installed or changed.
UPDATE:
I installed and done a basic setup with Symfony Encore in the hope I could at least get some CSS working. Still get the exact same issue.
symfony
add a comment |
I've just done a fresh install of the latest Symfony version. Inside my templates
folder I've created a new folder called website which contains a base.html.twig
and a home.html.twig
.
File structure: templates/website/base.html.twig
Inside my public
directory I've created the following css/app.css
. Now in my base I've done:
<link rel="stylesheet" href=" asset('css/app.css') " type="text/css">
Inside my stylesheet I'm just setting the body background colour to red so I know it works. For whatever reason it isn't loading my css. When I view source it appears as:
<link rel="stylesheet" href="/css/app.css" type="text/css">
and clicking the href I just get a Symfony 404. I cannot figure out why it isn't loading my static CSS file.
I don't want to use Symfony Encore as thats overcomplicating things for my project. I have also tried assets:install
command and nothing installed or changed.
UPDATE:
I installed and done a basic setup with Symfony Encore in the hope I could at least get some CSS working. Still get the exact same issue.
symfony
1
Which Symfony version are you using? Add a slash at the beginning of the pathasset('/css/app.css')
– Preciel
Mar 24 at 15:29
@Preciel No luck with the / at the start. Symfony version is 4.2.4
– Munch
Mar 24 at 15:32
One more thing you can try: if you open/css/app.css
in a browser and get the 404, try addingpublic
to the path so that you'll havepublic/css/app.css
. If you see your file then you know it's a config issue with the server.
– Dirk J. Faber
Mar 24 at 18:16
add a comment |
I've just done a fresh install of the latest Symfony version. Inside my templates
folder I've created a new folder called website which contains a base.html.twig
and a home.html.twig
.
File structure: templates/website/base.html.twig
Inside my public
directory I've created the following css/app.css
. Now in my base I've done:
<link rel="stylesheet" href=" asset('css/app.css') " type="text/css">
Inside my stylesheet I'm just setting the body background colour to red so I know it works. For whatever reason it isn't loading my css. When I view source it appears as:
<link rel="stylesheet" href="/css/app.css" type="text/css">
and clicking the href I just get a Symfony 404. I cannot figure out why it isn't loading my static CSS file.
I don't want to use Symfony Encore as thats overcomplicating things for my project. I have also tried assets:install
command and nothing installed or changed.
UPDATE:
I installed and done a basic setup with Symfony Encore in the hope I could at least get some CSS working. Still get the exact same issue.
symfony
I've just done a fresh install of the latest Symfony version. Inside my templates
folder I've created a new folder called website which contains a base.html.twig
and a home.html.twig
.
File structure: templates/website/base.html.twig
Inside my public
directory I've created the following css/app.css
. Now in my base I've done:
<link rel="stylesheet" href=" asset('css/app.css') " type="text/css">
Inside my stylesheet I'm just setting the body background colour to red so I know it works. For whatever reason it isn't loading my css. When I view source it appears as:
<link rel="stylesheet" href="/css/app.css" type="text/css">
and clicking the href I just get a Symfony 404. I cannot figure out why it isn't loading my static CSS file.
I don't want to use Symfony Encore as thats overcomplicating things for my project. I have also tried assets:install
command and nothing installed or changed.
UPDATE:
I installed and done a basic setup with Symfony Encore in the hope I could at least get some CSS working. Still get the exact same issue.
symfony
symfony
edited Mar 24 at 18:05
Munch
asked Mar 24 at 15:23
MunchMunch
391212
391212
1
Which Symfony version are you using? Add a slash at the beginning of the pathasset('/css/app.css')
– Preciel
Mar 24 at 15:29
@Preciel No luck with the / at the start. Symfony version is 4.2.4
– Munch
Mar 24 at 15:32
One more thing you can try: if you open/css/app.css
in a browser and get the 404, try addingpublic
to the path so that you'll havepublic/css/app.css
. If you see your file then you know it's a config issue with the server.
– Dirk J. Faber
Mar 24 at 18:16
add a comment |
1
Which Symfony version are you using? Add a slash at the beginning of the pathasset('/css/app.css')
– Preciel
Mar 24 at 15:29
@Preciel No luck with the / at the start. Symfony version is 4.2.4
– Munch
Mar 24 at 15:32
One more thing you can try: if you open/css/app.css
in a browser and get the 404, try addingpublic
to the path so that you'll havepublic/css/app.css
. If you see your file then you know it's a config issue with the server.
– Dirk J. Faber
Mar 24 at 18:16
1
1
Which Symfony version are you using? Add a slash at the beginning of the path
asset('/css/app.css')
– Preciel
Mar 24 at 15:29
Which Symfony version are you using? Add a slash at the beginning of the path
asset('/css/app.css')
– Preciel
Mar 24 at 15:29
@Preciel No luck with the / at the start. Symfony version is 4.2.4
– Munch
Mar 24 at 15:32
@Preciel No luck with the / at the start. Symfony version is 4.2.4
– Munch
Mar 24 at 15:32
One more thing you can try: if you open
/css/app.css
in a browser and get the 404, try adding public
to the path so that you'll have public/css/app.css
. If you see your file then you know it's a config issue with the server.– Dirk J. Faber
Mar 24 at 18:16
One more thing you can try: if you open
/css/app.css
in a browser and get the 404, try adding public
to the path so that you'll have public/css/app.css
. If you see your file then you know it's a config issue with the server.– Dirk J. Faber
Mar 24 at 18:16
add a comment |
2 Answers
2
active
oldest
votes
You should store your static files inside the assets
directory at the root of your project. So just place the css
-folder with the app.css
-file in <root>/assets/css/app.css
Source: https://symfony.com/doc/current/best_practices/web-assets.html
Didnt seem to make a difference. I moved my css file frompublic/css
toassets/css
and nothing changed
– Munch
Mar 24 at 15:30
What server setup do you use?
– Johan
Mar 24 at 15:33
It's a slightly modified version ofeko/docker-symfony
. My only change is removing the ELK part. I have this exact setup on another project which works and I cant see any differences
– Munch
Mar 24 at 15:36
add a comment |
If you want to use the asset
funtion you have to install the component first with the following command:
composer require symfony/asset
That is really all there is to it if you do not wish to use webpack encore.
Optional: If you happen to use PHPStorm with the Symfony plugin, go to settings > symfony and change Web Directory from app
to public
for the new directory that Symfony 4 uses. This gives you all the autocomplete goodness and your references will work.
Already tried the composer require a couple times and made no difference. I also have setup PHPStorm in that way. I even tried install Symfony Encore
– Munch
Mar 24 at 18:07
@Munch. my guess is this is a server issue. Maybe try with an absolute URL like so:
– Dirk J. Faber
Mar 24 at 18:11
absolute_url(asset('css/app.css'))
– Dirk J. Faber
Mar 24 at 18:11
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55325324%2fsymfony-doesnt-find-css-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You should store your static files inside the assets
directory at the root of your project. So just place the css
-folder with the app.css
-file in <root>/assets/css/app.css
Source: https://symfony.com/doc/current/best_practices/web-assets.html
Didnt seem to make a difference. I moved my css file frompublic/css
toassets/css
and nothing changed
– Munch
Mar 24 at 15:30
What server setup do you use?
– Johan
Mar 24 at 15:33
It's a slightly modified version ofeko/docker-symfony
. My only change is removing the ELK part. I have this exact setup on another project which works and I cant see any differences
– Munch
Mar 24 at 15:36
add a comment |
You should store your static files inside the assets
directory at the root of your project. So just place the css
-folder with the app.css
-file in <root>/assets/css/app.css
Source: https://symfony.com/doc/current/best_practices/web-assets.html
Didnt seem to make a difference. I moved my css file frompublic/css
toassets/css
and nothing changed
– Munch
Mar 24 at 15:30
What server setup do you use?
– Johan
Mar 24 at 15:33
It's a slightly modified version ofeko/docker-symfony
. My only change is removing the ELK part. I have this exact setup on another project which works and I cant see any differences
– Munch
Mar 24 at 15:36
add a comment |
You should store your static files inside the assets
directory at the root of your project. So just place the css
-folder with the app.css
-file in <root>/assets/css/app.css
Source: https://symfony.com/doc/current/best_practices/web-assets.html
You should store your static files inside the assets
directory at the root of your project. So just place the css
-folder with the app.css
-file in <root>/assets/css/app.css
Source: https://symfony.com/doc/current/best_practices/web-assets.html
answered Mar 24 at 15:26
JohanJohan
2,5681719
2,5681719
Didnt seem to make a difference. I moved my css file frompublic/css
toassets/css
and nothing changed
– Munch
Mar 24 at 15:30
What server setup do you use?
– Johan
Mar 24 at 15:33
It's a slightly modified version ofeko/docker-symfony
. My only change is removing the ELK part. I have this exact setup on another project which works and I cant see any differences
– Munch
Mar 24 at 15:36
add a comment |
Didnt seem to make a difference. I moved my css file frompublic/css
toassets/css
and nothing changed
– Munch
Mar 24 at 15:30
What server setup do you use?
– Johan
Mar 24 at 15:33
It's a slightly modified version ofeko/docker-symfony
. My only change is removing the ELK part. I have this exact setup on another project which works and I cant see any differences
– Munch
Mar 24 at 15:36
Didnt seem to make a difference. I moved my css file from
public/css
to assets/css
and nothing changed– Munch
Mar 24 at 15:30
Didnt seem to make a difference. I moved my css file from
public/css
to assets/css
and nothing changed– Munch
Mar 24 at 15:30
What server setup do you use?
– Johan
Mar 24 at 15:33
What server setup do you use?
– Johan
Mar 24 at 15:33
It's a slightly modified version of
eko/docker-symfony
. My only change is removing the ELK part. I have this exact setup on another project which works and I cant see any differences– Munch
Mar 24 at 15:36
It's a slightly modified version of
eko/docker-symfony
. My only change is removing the ELK part. I have this exact setup on another project which works and I cant see any differences– Munch
Mar 24 at 15:36
add a comment |
If you want to use the asset
funtion you have to install the component first with the following command:
composer require symfony/asset
That is really all there is to it if you do not wish to use webpack encore.
Optional: If you happen to use PHPStorm with the Symfony plugin, go to settings > symfony and change Web Directory from app
to public
for the new directory that Symfony 4 uses. This gives you all the autocomplete goodness and your references will work.
Already tried the composer require a couple times and made no difference. I also have setup PHPStorm in that way. I even tried install Symfony Encore
– Munch
Mar 24 at 18:07
@Munch. my guess is this is a server issue. Maybe try with an absolute URL like so:
– Dirk J. Faber
Mar 24 at 18:11
absolute_url(asset('css/app.css'))
– Dirk J. Faber
Mar 24 at 18:11
add a comment |
If you want to use the asset
funtion you have to install the component first with the following command:
composer require symfony/asset
That is really all there is to it if you do not wish to use webpack encore.
Optional: If you happen to use PHPStorm with the Symfony plugin, go to settings > symfony and change Web Directory from app
to public
for the new directory that Symfony 4 uses. This gives you all the autocomplete goodness and your references will work.
Already tried the composer require a couple times and made no difference. I also have setup PHPStorm in that way. I even tried install Symfony Encore
– Munch
Mar 24 at 18:07
@Munch. my guess is this is a server issue. Maybe try with an absolute URL like so:
– Dirk J. Faber
Mar 24 at 18:11
absolute_url(asset('css/app.css'))
– Dirk J. Faber
Mar 24 at 18:11
add a comment |
If you want to use the asset
funtion you have to install the component first with the following command:
composer require symfony/asset
That is really all there is to it if you do not wish to use webpack encore.
Optional: If you happen to use PHPStorm with the Symfony plugin, go to settings > symfony and change Web Directory from app
to public
for the new directory that Symfony 4 uses. This gives you all the autocomplete goodness and your references will work.
If you want to use the asset
funtion you have to install the component first with the following command:
composer require symfony/asset
That is really all there is to it if you do not wish to use webpack encore.
Optional: If you happen to use PHPStorm with the Symfony plugin, go to settings > symfony and change Web Directory from app
to public
for the new directory that Symfony 4 uses. This gives you all the autocomplete goodness and your references will work.
answered Mar 24 at 17:59
Dirk J. FaberDirk J. Faber
1,4401317
1,4401317
Already tried the composer require a couple times and made no difference. I also have setup PHPStorm in that way. I even tried install Symfony Encore
– Munch
Mar 24 at 18:07
@Munch. my guess is this is a server issue. Maybe try with an absolute URL like so:
– Dirk J. Faber
Mar 24 at 18:11
absolute_url(asset('css/app.css'))
– Dirk J. Faber
Mar 24 at 18:11
add a comment |
Already tried the composer require a couple times and made no difference. I also have setup PHPStorm in that way. I even tried install Symfony Encore
– Munch
Mar 24 at 18:07
@Munch. my guess is this is a server issue. Maybe try with an absolute URL like so:
– Dirk J. Faber
Mar 24 at 18:11
absolute_url(asset('css/app.css'))
– Dirk J. Faber
Mar 24 at 18:11
Already tried the composer require a couple times and made no difference. I also have setup PHPStorm in that way. I even tried install Symfony Encore
– Munch
Mar 24 at 18:07
Already tried the composer require a couple times and made no difference. I also have setup PHPStorm in that way. I even tried install Symfony Encore
– Munch
Mar 24 at 18:07
@Munch. my guess is this is a server issue. Maybe try with an absolute URL like so:
– Dirk J. Faber
Mar 24 at 18:11
@Munch. my guess is this is a server issue. Maybe try with an absolute URL like so:
– Dirk J. Faber
Mar 24 at 18:11
absolute_url(asset('css/app.css'))
– Dirk J. Faber
Mar 24 at 18:11
absolute_url(asset('css/app.css'))
– Dirk J. Faber
Mar 24 at 18:11
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55325324%2fsymfony-doesnt-find-css-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Which Symfony version are you using? Add a slash at the beginning of the path
asset('/css/app.css')
– Preciel
Mar 24 at 15:29
@Preciel No luck with the / at the start. Symfony version is 4.2.4
– Munch
Mar 24 at 15:32
One more thing you can try: if you open
/css/app.css
in a browser and get the 404, try addingpublic
to the path so that you'll havepublic/css/app.css
. If you see your file then you know it's a config issue with the server.– Dirk J. Faber
Mar 24 at 18:16