What about CSS? You're free to add whatever CSS you want to app/styles/app.css. That file is already loaded on the page.
Want to use Bootstrap CSS? Check out the Asset Mapper docs on how to do that. Or, if you want to use Sass, there's a symfonycasts/sass-bundle to make that easy. Though, I recommend not jumping into Sass too quickly. A lot of the features that Sass is famous for can now be done in native CSS, like CSS variables and even CSS nesting.
Hello Tailwind
What's my personal choice for a CSS framework? Tailwind. And part of the reason is that Tailwind is insanely popular. So if you're looking for resources or pre-built components, you're going to have a lot of luck if you use Tailwind.
But Tailwind is a bit odd in one way: it's not simply a big CSS file that you plop onto your page. Instead, it has a build process that scans your code for all the Tailwind classes you're using. It then dumps a final CSS file that only contains the code you need.
In the Symfony world, if you want to use Tailwind, there's a bundle that makes it really easy. Spin over your terminal and install a new package: composer require symfonycasts - hey I know them - tailwind-bundle:
composer require symfonycasts/tailwind-bundle
For this package, the recipe doesn't do anything other than enable the new bundle. To get Tailwind rocking, one time in your project, run:
php bin/console tailwind:init
This does three things. First, it downloads a Tailwind binary in the background, which you'll never really need to think about. Second, it creates a tailwind.config.js file at the root of our project. This tells Tailwind where it needs to look in our project for Tailwind CSS classes. And third, it updated our app.css to add these three lines. These will be replaced by the real Tailwind code in the background by the binary.
Running Tailwind
Finally, Tailwind needs to be built, so we need to run a command to do that:
php bin/console tailwind:build -w
This scans our templates and output the final CSS file in the background. The -w puts it in "watch" mode: instead of building once and exiting, it watches our templates for changes. When it notices any updates, it will automatically rebuild the CSS file. We'll see that in minute.
But we should already see a difference. Let's go to the homepage. Did you see that? The base Tailwind code did a reset. For example, our h1 is now tiny!
Seeing Tailwind in Action
Let's try this out for real. Open templates/main/homepage.html.twig. Up on the h1, make this bigger by adding a class: text-2xl.
| // ... lines 1 - 4 | |
| {% block body %} | |
| <h1 class="text-2xl"> | |
| Starshop: your monopoly-busting option for Starship parts! | |
| </h1> | |
| // ... lines 9 - 46 | |
| {% endblock %} |
As soon as we save that, you can see that tailwind noticed our change and rebuilt the CSS. And when we refresh, it got bigger!
Our source app.css file is still super simple - just those few lines we saw earlier. But view the page source and open the app.css that's being sent to our users. It's the built version from Tailwind! Behind the scenes, some magic exists that replaces those three Tailwind lines with the real Tailwind CSS code.
Automatically Running Tailwind with the symfony Binary
And... that's kind of it! It just works. Though there is an easier and more automatic way to run Tailwind. Hit Ctrl+C on the Tailwind command to stop it. Then, at the root of our project, create a file called .symfony.local.yaml. This is a config file for the symfony binary web server that we're using. Inside, add workers, tailwind, then cmd set to an array with each part of a command: symfony, console, tailwind, build, --watch, or you could use -w: it's the same.
I haven't talked about it yet, but instead of running php bin/console, we can also run symfony console followed by any command to get the same result. We'll talk about why you might want to do that in a future tutorial. But for now, consider bin/console and symfony console the same thing.
Also, by adding this workers key, it means that instead of us needing to run the command manually, when we start the symfony web server, it will run it for us in the background.
Watch. In your first tab, hit Ctrl+C to stop the web server... then re-run
symfony serve
so it sees the new config file. Watch: there it is! It's running the tailwind command in the background!
We can take advantage of this immediately. In homepage.html.twig, change this to text-4xl, spin over and... it works! We don't even need to think about the tailwind:build command anymore.
| // ... lines 1 - 4 | |
| {% block body %} | |
| <h1 class="text-4xl"> | |
| Starshop: your monopoly-busting option for Starship parts! | |
| </h1> | |
| // ... lines 9 - 46 | |
| {% endblock %} |
And since we'll be styling with Tailwind, remove the blue background.
Copying in Styled Templates
Ok, this tutorial is not about Tailwind or how to design a website. Trust me, you do not want Ryan leading the web design charge. But I do want to have a nice-looking site... and it's also important to go through the process of working with a designer.
So let's pretend that someone else has created a design for our site. And they've even given us some HTML with Tailwind classes for that design. If you download the course code, in a tutorial/templates/ directory, we have 3 templates. One-by-one, I'm going to copy each file and paste it over the original. Don't worry, we'll look at what's happening in each of these files.
| <html> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>{% block title %}Welcome!{% endblock %}</title> | |
| <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>⚫️</text></svg>"> | |
| {% block stylesheets %} | |
| {% endblock %} | |
| {% block javascripts %} | |
| {% block importmap %}{{ importmap('app') }}{% endblock %} | |
| {% endblock %} | |
| </head> | |
| <body class="text-white" style="background: radial-gradient(102.21% 102.21% at 50% 28.75%, #00121C 42.62%, #013954 100%);"> | |
| <div class="flex flex-col justify-between min-h-screen relative"> | |
| <div> | |
| <header class="h-[114px] shrink-0 flex flex-col sm:flex-row items-center sm:justify-between py-4 sm:py-0 px-6 border-b border-white/20 shadow-md"> | |
| <a href="#"> | |
| <img class="h-[42px]" src="{{ asset('images/starshop-logo.png') }}" alt="starshop logo"> | |
| </a> | |
| <nav class="flex space-x-4 font-semibold"> | |
| <a class="hover:text-amber-400 pt-2" href="#"> | |
| Home | |
| </a> | |
| <a class="hover:text-amber-400 pt-2" href="#"> | |
| About | |
| </a> | |
| <a class="hover:text-amber-400 pt-2" href="#"> | |
| Contact | |
| </a> | |
| <a class="rounded-[60px] py-2 px-5 bg-white/10 hover:bg-white/20" href="#"> | |
| Get Started | |
| </a> | |
| </nav> | |
| </header> | |
| {% block body %}{% endblock %} | |
| </div> | |
| <div class="p-5 bg-white/5 mt-3 text-center"> | |
| Made with ❤️ by <a class="text-[#0086C4]" href="https://symfonycasts.com">SymfonyCasts</a> | |
| </div> | |
| </div> | |
| </body> | |
| </html> |
Do homepage.html.twig...
| {% extends 'base.html.twig' %} | |
| {% block title %}Starshop: Beam up some parts!{% endblock %} | |
| {% block body %} | |
| <main class="flex flex-col lg:flex-row"> | |
| <aside | |
| class="pb-8 lg:pb-0 lg:w-[411px] shrink-0 lg:block lg:min-h-screen text-white transition-all overflow-hidden px-8 border-b lg:border-b-0 lg:border-r border-white/20" | |
| > | |
| <div class="flex justify-between mt-11 mb-7"> | |
| <h2 class="text-[32px] font-semibold">My Ship Status</h2> | |
| <button> | |
| <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 448 512"><!--!Font Awesome Pro 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2024 Fonticons, Inc.--><path fill="#fff" d="M384 96c0-17.7 14.3-32 32-32s32 14.3 32 32V416c0 17.7-14.3 32-32 32s-32-14.3-32-32V96zM9.4 278.6c-12.5-12.5-12.5-32.8 0-45.3l128-128c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3L109.3 224 288 224c17.7 0 32 14.3 32 32s-14.3 32-32 32l-178.7 0 73.4 73.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0l-128-128z"/></svg> | |
| </button> | |
| </div> | |
| <div> | |
| <div class="flex flex-col space-y-1.5"> | |
| <div class="rounded-2xl py-1 px-3 flex justify-center w-32 items-center" style="background: rgba(255, 184, 0, .1);"> | |
| <div class="rounded-full h-2 w-2 bg-amber-400 blur-[1px] mr-2"></div> | |
| <p class="uppercase text-xs">in progress</p> | |
| </div> | |
| <h3 class="tracking-tight text-[22px] font-semibold"> | |
| <a class="hover:underline" href="{{ path('app_starship_show', { | |
| id: myShip.id | |
| }) }}">{{ myShip.name }}</a> | |
| </h3> | |
| </div> | |
| <div class="flex mt-4"> | |
| <div class="border-r border-white/20 pr-8"> | |
| <p class="text-slate-400 text-xs">Captain</p> | |
| <p class="text-xl">{{ myShip.captain }}</p> | |
| </div> | |
| <div class="pl-8"> | |
| <p class="text-slate-400 text-xs">Class</p> | |
| <p class="text-xl">{{ myShip.class }}</p> | |
| </div> | |
| </div> | |
| </div> | |
| </aside> | |
| <div class="px-12 pt-10 w-full"> | |
| <h1 class="text-4xl font-semibold mb-8"> | |
| Ship Repair Queue | |
| </h1> | |
| <div class="space-y-5"> | |
| <!-- start ship item --> | |
| <div class="bg-[#16202A] rounded-2xl pl-5 py-5 pr-11 flex flex-col min-[1174px]:flex-row min-[1174px]:justify-between"> | |
| <div class="flex justify-center min-[1174px]:justify-start"> | |
| <img class="h-[83px] w-[84px]" src="/images/status-in-progress.png" alt="Status: in progress"> | |
| <div class="ml-5"> | |
| <div class="rounded-2xl py-1 px-3 flex justify-center w-32 items-center bg-amber-400/10"> | |
| <div class="rounded-full h-2 w-2 bg-amber-400 blur-[1px] mr-2"></div> | |
| <p class="uppercase text-xs text-nowrap">in progress</p> | |
| </div> | |
| <h4 class="text-[22px] pt-1 font-semibold"> | |
| <a | |
| class="hover:text-slate-200" | |
| href="#" | |
| >USS LeafyCruiser</a> | |
| </h4> | |
| </div> | |
| </div> | |
| <div class="flex justify-center min-[1174px]:justify-start mt-2 min-[1174px]:mt-0 shrink-0"> | |
| <div class="border-r border-white/20 pr-8"> | |
| <p class="text-slate-400 text-xs">Captain</p> | |
| <p class="text-xl">Jean-Luc Pickles</p> | |
| </div> | |
| <div class="pl-8 w-[100px]"> | |
| <p class="text-slate-400 text-xs">Class</p> | |
| <p class="text-xl">Garden</p> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- end ship item --> | |
| </div> | |
| <p class="text-lg mt-5 text-center md:text-left"> | |
| Looking for your next galactic ride? | |
| <a href="#" class="underline font-semibold">Browse the {{ ships|length * 10 }} starships for sale!</a> | |
| </p> | |
| </div> | |
| </main> | |
| {% endblock %} |
and finally show.html.twig.
| {% extends 'base.html.twig' %} | |
| {% block title %}{{ ship.name }}{% endblock %} | |
| {% block body %} | |
| <div class="my-4 px-8"> | |
| <a class="bg-white hover:bg-gray-200 rounded-xl p-2 text-black" href="#"> | |
| <svg class="inline text-black" xmlns="http://www.w3.org/2000/svg" height="16" width="14" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path fill="#000" d="M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.2 288 416 288c17.7 0 32-14.3 32-32s-14.3-32-32-32l-306.7 0L214.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z"/></svg> | |
| Back | |
| </a> | |
| </div> | |
| <div class="md:flex justify-center space-x-3 mt-5 px-4 lg:px-8"> | |
| <div class="flex justify-center"> | |
| <img class="max-h-[300px] md:max-h-[500px]" src="{{ asset('images/purple-rocket.png') }}" alt="purple ship launching"> | |
| </div> | |
| <div class="space-y-5"> | |
| <div class="mt-8 max-w-xl mx-auto"> | |
| <div class="px-8 pt-8"> | |
| <div class="rounded-2xl py-1 px-3 flex justify-center w-32 items-center bg-amber-400/10"> | |
| <div class="rounded-full h-2 w-2 bg-amber-400 blur-[1px] mr-2"></div> | |
| <p class="uppercase text-xs">{{ ship.status }}</p> | |
| </div> | |
| <h1 class="text-[32px] font-semibold border-b border-white/10 pb-5 mb-5"> | |
| {{ ship.name }} | |
| </h1> | |
| <h4 class="text-xs text-slate-300 font-semibold mt-2 uppercase">Spaceship Captain</h4> | |
| <p class="text-[22px] font-semibold">{{ ship.captain }}</p> | |
| <h4 class="text-xs text-slate-300 font-semibold mt-2 uppercase">Class</h4> | |
| <p class="text-[22px] font-semibold">{{ ship.class }}</p> | |
| <h4 class="text-xs text-slate-300 font-semibold mt-2 uppercase">Ship Status</h4> | |
| <p class="text-[22px] font-semibold">30,000 lys to next service</p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| {% endblock %} |
Tip
If you copy the files (instead of the file contents), Symfony's cache system
may not notice the change and you won't see the new design. If that happens,
clear the cache by running php bin/console cache:clear.
I'm going to delete the tutorial/ directory entirely so I don't get confused and edit the wrong templates.
Ok, let's see what this did! Refresh. It looks beautiful! I love working inside a nice design. But... some parts are broken. In homepage.html.twig, this is our ship repair queue... which looks nice... but there's no Twig code! The status is hardcoded, name is hardcoded and there's no loop.
| // ... lines 1 - 4 | |
| {% block body %} | |
| <main class="flex flex-col lg:flex-row"> | |
| // ... lines 7 - 42 | |
| <div class="px-12 pt-10 w-full"> | |
| <h1 class="text-4xl font-semibold mb-8"> | |
| Ship Repair Queue | |
| </h1> | |
| <div class="space-y-5"> | |
| <!-- start ship item --> | |
| <div class="bg-[#16202A] rounded-2xl pl-5 py-5 pr-11 flex flex-col min-[1174px]:flex-row min-[1174px]:justify-between"> | |
| <div class="flex justify-center min-[1174px]:justify-start"> | |
| <img class="h-[83px] w-[84px]" src="/images/status-in-progress.png" alt="Status: in progress"> | |
| <div class="ml-5"> | |
| <div class="rounded-2xl py-1 px-3 flex justify-center w-32 items-center bg-amber-400/10"> | |
| <div class="rounded-full h-2 w-2 bg-amber-400 blur-[1px] mr-2"></div> | |
| <p class="uppercase text-xs text-nowrap">in progress</p> | |
| </div> | |
| <h4 class="text-[22px] pt-1 font-semibold"> | |
| <a | |
| class="hover:text-slate-200" | |
| href="#" | |
| >USS LeafyCruiser</a> | |
| </h4> | |
| </div> | |
| </div> | |
| <div class="flex justify-center min-[1174px]:justify-start mt-2 min-[1174px]:mt-0 shrink-0"> | |
| <div class="border-r border-white/20 pr-8"> | |
| <p class="text-slate-400 text-xs">Captain</p> | |
| <p class="text-xl">Jean-Luc Pickles</p> | |
| </div> | |
| <div class="pl-8 w-[100px]"> | |
| <p class="text-slate-400 text-xs">Class</p> | |
| <p class="text-xl">Garden</p> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- end ship item --> | |
| </div> | |
| // ... lines 80 - 84 | |
| </div> | |
| </main> | |
| {% endblock %} |
Next: let's take our new design and make it dynamic. We'll also learn how to organize things into template partials and introduce a PHP enum, which are fun.
62 Comments
Hi guys, just a note for people using Windows and WSL.
I had issues with hot reload which I solved using this thread and simply moving the project from
/mnt/c/path/to/repoto/home/user/path/to/repodid the following:php bin/console tailwind:build --watchactually rebuilds when I change a twig fileHey Andrei,
Thanks for sharing these tips to our Windows friends :) I like your performance boost also, sounds great!
Cheers!
How do you auto run the watcher in a docker container when you start the container with docker compose up? I'm using this https://github.com/dunglas/symfony-docker
Hey @sfr
That's a great question. I think you can do what they say in this post https://github.com/dunglas/symfony-docker/issues/475#issuecomment-3634160207
define the command in the
tailwindcontainerCheers~
Hello there,
For all like me struggling with tailwind not working as expected since V4 :
Do not downgrade tailwind, adapt the app.css like :
@tailwind base;@tailwind components;@tailwind utilities;@import "tailwindcss";You can see this on this official page : https://tailwindcss.com/docs/upgrade-guide#removed-tailwind-directives
Thanks @Symio!
I think the
init commandshould bootstrap you correctly based on which version of tailwind you have. However our code download for the course has the v3 init code: so if you update to a v4 insymfonycasts_tailwind.yaml, you'll have issues.I appreciate your comment.
Cheers!
Anyone else encounter this error when running
symfony serveafter installing tailwind?Browserslist: caniuse-lite is outdated. Please run:{"level":"debug","source":"runner","cmd":"tailwind","time":"2025-04-17T11:25:13+08:00","message":"Received timer message (first boot)"}Hey Skribe,
That's fine. You only need to update
caniuse-liteif it's actually causing you troubles, otherwise, just ignore it.To update it, you can run
yarn update-browserslist-db --updateCheers!
Hi all!
I'm having trouble getting Tailwind CSS autocompletion to work in PHPStorm for my Twig templates. I've searched everywhere in the settings but can't get it to work properly.
Could someone help me set up Tailwind CSS autocompletion correctly in PHPStorm for Twig files?
Thanks in advance for your help!
Hey Simston!
Sorry for my super late reply, I missed your message somehow. Perhaps you already solved your problem but here's a list of things you can try (I got it from ChatGPT, but went through it and looks good to me)
Install the Tailwind CSS plugin
Enable Tailwind CSS for your project
After plugin installation:
⚠️ Warning: this step may cause false positives or issues with Twig-specific syntax, so use it only if you're okay with treating Twig as HTML.
I hope it helps. Cheers!
Read that symfony doesn't currently support tailwind 4.*
I'm thinking of trying few things i read online and in forums to fix it. Anyways, it brings another question I just can't seem to google out:
How do I uninstall any particular(bundle,package, or whatever they are called) from my project ? In this case tailwind, with all the related files.
Hey @John-S,
Tailwind 4 support is coming soon: https://github.com/SymfonyCasts/tailwind-bundle/pull/91
composer remove the/packageremoves the actual package but there might be some things left - each bundle is different. You may need to manually remove the bundle and config. In the case of tailwind-bundle, you'd need to remove some stuff from your css file.Hi, I got into trouble with the
tailwind:initcommand.The moment I call it, something like Windows Smart-screen pops up and refuses to run the application: https://ibb.co/wFzXWv8m
In translation it says something like: "This app can't run on your computer".
I then see this in the console, translated as something like: "Access denied. [ERROR] Tailwind CSS init failed: see output above"
Even if I turn off antivirus, even if I turn off everything in Windows around security, no change.
Any clue?
Hey Ondrej,
It's difficult to say for me because I don't use Windows.. but it should work on Windows as well. Probably some problems specific to your computer. I would recommend you try to install the Tailwind yourself and try its binary to see it works well. Then just point the bundle to the binary you installed, see the docs how to do it: https://symfony.com/bundles/TailwindBundle/current/index.html#using-a-different-binary
It's more like a workaround, but I hope that helps this way.
Cheers!
I tried the "Using a different binary", but no matter I write to the config it seems it doesn't matter. Like the error fires up before even get there.
I did some debugging to see, where it happens and it's right here:
\Symfonycasts\TailwindBundle\Command\TailwindInitCommand::createTailwindConfigon line 61When I go to the wait function
\Symfony\Component\Process\Process::waitit happens right in the do/while block on the line 453.The error triggers the code
$this->readPipes($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);, not the previous ones.But funny is - the code gets to the
readPipesmethod, can run twice and after that it shows the error. It's like the system doesn't min the method itself, but rather the fact it runs in cycles and stops it after a while.Can you see something suspicious there?
Hey Ondrej,
Hm, really not sure... It sounds like you're having trouble with the binary on your computer. The best option would be to try to google how to install Tailwind correctly on your specific platform. After you install it properly - try to run the installed binary directly. The idea is if that will work for your platform directly, it should also work for you with the bundle.
Cheers!
Ok I think a solved the problem. It was actually two problems, one hiding behind the other one.
All the Windows errors "This app can't run on your computer" was because when the commands tried to run the tailwind client in
var/tailwind/v3.4.17, they actually tried to run an exe file with zero size. Just an empty file. And for some reason in Windows the error looks like that.So what was the original problem? Why was there such a broken file?
When I initially run the
tailwind:init, my "awesome" antivir AvastOne was so eager to make false/positive detection, it apparently blocked downloading the file in this most terrible way - not saying anything a creating the file but empty. I actually had more problems with the Avast in last days - I had to whitelist all urls important for devs, like github, packagist etc, because I wasn't even able to run normalcomposer installcommand.The funny thing was, that I of course tried to turn of the antivir and even uninstall it, but every time I tried your steps from the beginning, the
tailwind:initnever tried to override the broken cli. It just checked it's there and thought "Ok, I'll just use it".I finally tried to delete all the files and now, the
initcommand worked because new antivir didn't the downloading.So I just wanted to describe it and maybe help someone in the future.
The most funny thing? I don't even wanna use Tailwind, I don't like the way it work and I prefer clean HTML structure and I was able to easily continue the lessons without it :D
But thank you Victor for your effort.
Hi Ondrej-Vasicek. I've been facing the same
This app can't run on your PCerror when I try to runphp bin/console tailwind:buildcommand. So I'd kindly like to know how did you solve this issue.Hi, I've described it in the previous post - in a nutshell - antivir program blocked creating proper exe file and created only empty file. When executing empty file, Windows has this error message. So the solution was to (unfortunately) change my antivir and start the proces over again, so the exe file was created/downloaded again properly. More info in the previous post.
Hey Ondrej,
Happy to hear you found the problem! Yeah, that makes sense, the bundle does not override if the file exists and no any sum checks on the existent file for some performance reasons. So you just need to manually drop that corrupted file.
Thanks for sharing the solution with others, I think most Windows users may face this problem, so it should be useful to them for sure.
Cheers!
Just ran into the same issue with Windows Defender (1.1.25080.5) on Windows 10 22H2 with PHP 8.4, Symfony 7.3 and TailwindCSS 4.
Temporary solution
Removing the bundle via composer, disabling Defender and reinstalling the bundle, and running
initagain and then thebuildcommand "fixed it for now." What I noticed was that theinitcommand didn't download the executable, but thebuildcommand did.I saw there is a closed issue [98] on this in the GitHub repository with a "fix." But as this at least partially is playing into antivirus behavior, it seems like it should be looked into further, my assumption out of the blue is that Defender (and probably other AVs too) doesn't want to play nice with downloading the executable here for some reason (a common way of backloading malware), and that then results in the 0-byte file, which throws the SmartScreen error when it's attempted to be executed with the
buildcommand. If that would be the case, my guess is thatdownloadExecutable()is to blame, but I sadly don't have a "permanent fix" for this issue.Hey Taminoful,
Thanks for sharing your working solution with others! Hm, indeed some antiviruses may case issues with downloading executable, probably depends on the antivirus config. I'm not sure if we can do much with it, moreover I'm not on wondows so it's harder to reproduce for me. But if you say it creates an empty file - that may lead to not clear error I suppose. I'm not sure if we should check the file size and throw if it's empty, not sure if there's a better way to check for file corruption in this case. If you have some ideas how to improve or make the process more robust - please, feel free to send a PR or open an issue to discuss first.
Cheers!
Hey there Victor,
I've gone ahead and opened an issue for discussing potential fixes for this issue, recapping the situation on the repo now. I'll help out and brainstorm solutions as much as my time allows me to, went ahead and proposed some solutions in there too.
Happy to help! :)
Hey Taminoful,
Awesome, thanks for opening the issue on it! And thanks for helping with brainstorming the solutions ❤️
Cheers!
For anyone still reading down this far, this is what I had to do to resolve the "PC cannot run app" error when I ran the command "php bin/console tailwind:build -w". As described by "Ondrej-Vasicek" my Windows11 Defender blocked the download in the most unhelpful way and ".exe" file was size 0kbs. When I ran the build command with the additional flag "-v" I could see the url for the file that was "blocked" as "https://github.com/tailwindlabs/tailwindcss/releases/download/v4.1.11/tailwindcss-windows-x64.exe " (Your url may be different depending on your tailwind version)
I put this into my browser (chrome) and the exe was downloaded without an issue. No idea why.
I then put the downloaded exe into the directory "[project_name]/var/tailwind/v[version_number]/". You many need to delete or replace the empty exe if it is still there. I was able to continue the tutorial from there.
Hope this helps.
Note that I did try a few ways to disable/work-around Win11 Defender but they did not help me.
Hey Ben,
Thanks for sharing your solution. Yeah, it's weird that the file is not blocked when you download it from the browser, probably some trustworthy user interaction, I'm not sure. Well, as always, Windows has its own quirks :)
Cheers!
Hello everyone. I'm facing an issue here, I followed all steps from installing tailwind-bundle to creating '.symfony.local.yaml', with the right content inside, and when the server starts, it shows
[ok] Started worker "tailwind", but when I add 'text-2xl' class, it doesn't reflect on the browser. I reviewed app.css on page source, it actually has all content from /var/tailwind/app.built.css file, but failed to have 'text-2xl' class in it. I'm using Windows OS.Hey Lemin,
How does your
.symfony.local.yamlconfig file look like? As an alternative solution, you can comment out that Tailwind command in.symfony.local.yamland instead run it in a separate console tab to make sure it works this way. Also, what OS are you on?Cheers!
Hi Victor, I tried to run the command in a separate Windows terminal tab at first, but as I add classes it doesn't seem to track class changes in twigs templates, and nothing takes effect on the browser . I'm using Windows 10.
Hey Lemin,
Hm, probably a known issue, if you add that class in a CSS file that you include in the main CSS file, IIRC files including may not work well. Could you try to add that CSS class directly in the main CSS file which is app.css I suppose? Will it work for you?
Cheers!
Hi Victor. I can now see it seems to work for all templates except the 'homepage.html.twig' which is being rendered by Main controller:: homepage action.
Hey Lemin,
Hm, make sure you don't override any stylesheet blocks in your homepage.hrml.twig. In theory, if it works in other templates but doesn't in one - then most probably you either have some inconsistency in your code for that page, worth double-checking... or it might be a browser cache problem, try to open Chrome's dev toolbar and do a hard reload of the page, in most cases it should help.
Cheers!
Finally solved. The error in render() rendering
homepage.thml.twiginstead ofhomepage.html.twig.Thank Victor
Hey Lemin,
Great, glad to hear you nailed it :)
Cheers!
i got an error
Hey @Himanshu ,
Probably a temporary network issue in your region? Does the GitHub website work well for you? Could you open that https://github.com/tailwindlabs/tailwindcss/releases/download/v3.4.17/tailwindcss-windows-x64.exe link in your browser? Does it download the file for you? If it works - could you try again?
Cheers!
Working successfully :)
Hey Himanshu,
Awesome, thanks for confirming it worked eventually :)
Cheers!
Anyone uses VS code ?
I'm getting: "spawn /usr/bin/php ENOENT" code error on it.
on "symfony server:start " i'm getting:
Workers PID 12968: C:\xampp\php\php-cgi.exe -b 49773 -d error_log=C:\Users\wuwu5.symfony5\log\cd0ebfaea3f058bd6bb595d3f05f2e1a2651620f.log
checked the log files but it was empty. tried changing php path several times but it didn't work.
Hey John,
I personally don't use VS code so can't help you much on it. I see you're on Windows OS and sue XAMPP, could you make sure the XAMPP is started and working? Maybe try to reload it.
Also, the error "spawn /usr/bin/php ENOENT" usually indicates that the system is unable to find PHP at the specified path (/usr/bin/php), which could be due to a misconfiguration in your environment. Please, make sure the path you're using to the PHP is correct. There are a few commands that may help you to debug it:
Probably you need to refresh your PHP versions first, and then make sure the list command shown the correct path to the correct PHP.
Also, check your
.vscode/settings.jsonto make sure there are no path to the invalid PHP binary, fix the path if needed. IIRC it should be something likephp.executablePathconfig parameter there.I hope that helps!
Cheers!
Could you please share how you made the tailwind css intellisense and autocomplete work with Phpstorm?
Tailwind plugin installed - Yes
All instructions per course followed - Yes
Tailwind is initialized. Command to watch and rebuild works fine. Just the IDE intellisense and autocomplete isn't working. I suspect this has to do with us not using node modules for tailwind and just using the tailwind-cli. Not an expert on this. Any guidance to fix this is much appreciated. Thanks in advance.
Hey Jake!
Your totally right: it's because the
node_modulesisn't there, which is really annoying! I think that I'm getting some autocompletion in PhpStorm simply because it recognizes me using Tailwind classes (and maybe it sees mytailwind.config.js. But I don't think I've done anything extra! Here's some info on this topic: https://github.com/SymfonyCasts/tailwind-bundle/issues/28 including a link to the issue for PhpStorm where you can upvote!You can also install Tailwind via npm just to get the autocompletion. Annoying, but functional.
Cheers!
Just a follow up question. I am planning to use daisyui components. With the asset mapper, the only way I found sane is to use a custom standalone tailwind cli with prepackaged daisyui. Is there a way to take advantage of this binary when installing tailwindcss using the symfonycasts bundle? For now I replaced the binary manually inside folder var/tailwind/3.x.x/
https://github.com/dobicinaitis/tailwind-cli-extra/releases
Thanks in advance 🙏🙏🙏🙏🙏🙏🙏🙏
Hey @Jake!
I'm pretty sure this is possible! You'd need to manually download that binary and have the tailwind bundle point to it (instead of its default). See https://symfony.com/bundles/TailwindBundle/current/index.html#using-a-different-binary for how to configure that.
I'm curious to see if that would work so let us know!
Works like a charm! thank you.
Thanks Ryan! I did just that. Annoying but it works! But frustrating when it didn't work.
npm install -D tailwindcss
Hi,
Does it has a LiveReloader ? - edit twig template and see changes immediately in browser
Thank you.
Hey Ruslan,
TailwindCSS itself does not include a built-in live reloading feature, but I think you can easily set up live reloading using development tools commonly used with TailwindCSS. Live reloading is typically handled by tools like Webpack or Vite, though I have never done it before, so not sure about the exact code.
I hope that helps!
Cheers!
Hi there,
I've spoted an issue with tailwind intelisense in PhpStorm on asset mapper that there is no class autocomplete (text-2+enter = text-2xl). I've tested it with bootstrap, and webpack encore on tailwind and it work perfectly fine. I also did so on vscode and it works on base project. Tailwind as is works, i mean classes are applyed, only way to see them is by
symfony console assets:installbut only for currently used class. Do you have idea why?Project made by running
symfony new name --webappand following commands on video.Hey HardWare,
There's a "Tailwind CSS" PhpStorm plugin, I bet if you install that - you will have auto-completion for all Tailwind CSS classes, not only those you've used before in the project :)
Cheers!
"Houston: no signs of life"
Start the conversation!