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;








0















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.










share|improve this question



















  • 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 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

















0















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.










share|improve this question



















  • 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 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













0












0








0








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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 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












  • 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 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







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












2 Answers
2






active

oldest

votes


















0














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






share|improve this answer























  • 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











  • 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


















0














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.






share|improve this answer























  • 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











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
);



);













draft saved

draft discarded


















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









0














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






share|improve this answer























  • 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











  • 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















0














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






share|improve this answer























  • 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











  • 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













0












0








0







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






share|improve this answer













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







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 24 at 15:26









JohanJohan

2,5681719




2,5681719












  • 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











  • 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

















  • 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











  • 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
















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













0














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.






share|improve this answer























  • 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















0














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.






share|improve this answer























  • 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













0












0








0







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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










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

















  • 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

















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript