Charming Development in Symfony 5

1:50:35

What you'll be learning

Symfony 5 is here! And you are going to love it! It builds on the revolutionary progress of Symfony 4 but with tons of new features and a more streamlined experience so you can get your work done fast and enjoy the process!

Ready, set, code!

  • Create your shiny (and tiny!) new Symfony app
  • Install the symfony binary & explore its superpowers
  • Configure PhpStorm & plugins for a killer experience
  • Symfony Flex & the "recipes" system
  • Install 3rd party packages and bundles
  • Create routes and controllers
  • The bin/console tool
  • Twig & templating
  • The web debug toolbar: insane debugging at your fingertips
  • JavaScript & Asset Setup
  • Create a JSON API endpoint & consume with AJAX
  • An intro to the most important part of Symfony: services!

Upgrading to Symfony 5? See Upgrade to Symfony5


Your Guides

Ryan Weaver


Questions? Conversation?

  • 2020-07-03 weaverryan

    Hey Ivan!

    Hmm, I'm not sure about that. Since this is done by the Symfony binary, I would open up an issue here: https://github.com/symfony/cli

    Cheers!

  • 2020-07-02 Ivan

    I am not sure if this is the right place, but when trying to build the guestbook project from the the new symfony 5 book, the build fails with the following error msg:

    ---
    [SPA] Building CSS and JS assets
    unable to get the URL of the local web server: exit status 1

    ---

    I do meet all requirements and have passed everything.
    What am I missing, what have I done wrong? I am running everything on pop_os 20.04 (ubuntu 20.04)

  • 2020-04-30 Max

    Thanks weaverryan - I'll take look at the suggested tutorials as well as the API Platform next while the Doctrine for Symfony 5 gets built. Appreciate it!

  • 2020-04-30 weaverryan

    Hey @Max!

    Very happy it was useful for you :). The database tutorial, unfortunately, is not out yet - I just finished the *next* course in this series - https://symfonycasts.com/sc... - yesterday - and will start working on the Doctrine (database) tutorial next. If you can't wait (I totally get it!) our Symfony 4 Doctrine tutorial will still be *very* relevant - not a lot of critical things have changed - https://symfonycasts.com/sc...

    Cheers!

  • 2020-04-30 Max

    Great tutorial! There are a few times when it is mentioned that the tutorial will show how to read/write the votes to/from the database. Are those sections somewhere or have they not been published yet? Thanks.

  • 2020-04-28 Diego Aguiar

    Yes, you should never activate the debug tool bar in your production machine. What you can do is to create and deploy a "beta" site, and test things there

  • 2020-04-28 Chuck Norris

    Hi Diego Aguiar ,

    Thanks for your answer, its really helpful.

    I understand that its a matter of security, so there is no longer a "safe way" to access the symfony debug tool bar apart from a local machine ?

  • 2020-04-27 Diego Aguiar

    Hey Chuck Norris

    You can't :) - unless you create your own app_dev.php file, but remember to delete it when you deploy to production

    Cheers!

  • 2020-04-27 Chuck Norris

    Hi,
    thanks for this great symfony course.

    I have a trivial question :

    In symfony 2 and 3, it was very easy to debug in a browser with the app_dev.php resource, even on a production server.
    But since Symfony 4, its using environment variable.
    How do you tell your browser to access the dev, the test or the prod environment without changing every time your .env file ?

    Thanks for any help :)

  • 2020-04-16 Oleksii

    thanks a lot for this tutorial! It was more than usefull for me as Symfony-starter with basis programming knowledges

  • 2020-03-22 weaverryan

    Hey Patrick!

    Thanks for your nice words ❤️. I agree with you! And... I also agree with Jack - I think he just wanted to make sure that these beginner courses aren't the *only* ones that we're releasing - we need something for everyone :).

    Btw, the first Deep Dive course I mentioned earlier (Jack gave me a push to get this one done) will start releasing tomorrow (Monday): https://symfonycasts.com/sc...

    Cheers!

  • 2020-03-22 Patrick

    I think that this is just the begginer course. For people starting from zero. It's is not boring. It's is helpful for begginers. I don't understand your offensive comments there. If you want teach more you mast paid for it.

  • 2020-03-09 wuwu

    OPcache ✗ - is in red color :), so i guess that was the problem. Thank you a lot for your effort.

  • 2020-03-05 weaverryan

    Hey @wuwu!

    Ok, excellent information here! There are 2 things I will say:

    A) You noticed that the first request is slow, and then it's much faster on the second request. That's 100% correct :). On the first request, Symfony builds its cache. Then on later requests, it doesn't need to do that. When you change certain files, you will notice that the request is AGAIN slow. That's because Symfony detects that the change to that file requires it to rebuild its cache. The good news is that this will NOT happen on production. When you deploy, you run a command that "warms" all your cache. Then, every request on production NEVER builds the cache and will be much faster.

    B) But, the cache building should also not be NEARLY that slow. I'm *this* it might be related to your filesystem. For some reason, your filesystem is slow. Symfony *reads* a lot of files on your filesystem - especially when it's building its cache. If there is any filesystem slowdown, this is where you can feel it. But, I can't think of *what* would be slow: you're doing all your development locally, so there is no "network mounted filesystems" or anything like that. Even if your hard drive is a little slow, I wouldn't expect it to take this long of time.

    There is one other possibility: do you have OPCache enabled in PHP? Here is how you can find out. On the web debug tooolbar, on the bottom right, hover over Symfony version and click "View phpinfo()". On that screen, search for "OPcache": you should see a section like this: https://imgur.com/undefined

    If you *don't* see this, that's your problem. Check into how OPcache should be enabled for xampp.

    Let me know what you find out!

    Cheers!

  • 2020-03-05 wuwu

    Symfony demo app:
    kernel.request 816.1 ms / 12 Mb
    raceableFirewallListener 427 ms / 12 Mb
    controller.get_callable 402 ms / 14 Mb
    controller 1835.1 ms / 16 Mb
    default/homepage.html.twig 712 ms / 14 Mb

    etc.

    my system is pretty slow( celeron dual core 2.8ghz , 4gb ram). It's not the code because skeleton and symfony demo also takes long time. Must be something with the server setup i hope. My setup: installed apache-pack, C:\Windows\System32\drivers\etc\hosts.file - added 127.0.0.1 sf.test) and updated httpd-vhosts.conf as:

    <virtualhost sf.test="">
    DocumentRoot "C:/xampp/htdocs/sf/public"
    ServerName sf.test
    <directory "c:="" xampp="" htdocs="" sf"="">
    AllowOverride All
    Require local
    </directory>
    </virtualhost>

    it takes 0.3 secs on subsequent request.It's not an actual problem since the app is not in production but it was strange and i'm just a bit worried. Fingers crossed it's just local :)

  • 2020-03-04 weaverryan

    Hi @wuwu!

    Wow! Now, that is WAY slower than it should be under any situation. When I'm developing in the first chapters (with the "empty" skeleton), my response time is about 50ms. Try this:


    composer require profiler --dev

    Now, when you refresh, you will have a web debug toolbar on the bottom of the page (we talk about this a few chapters from now). One if the icons on this will be the response time. If you click this, you will go into a full-page "timeline" where it shows you which parts of the application are taking the most time. This may contain a hint about what's going on.

    Generally-speaking, when something is THIS slow, it's often due to the filesystem. You mentioned xampp, which is a pretty "normal" development environment. Usually when something is this slow, it's because people are using Docker and have network mounts... or something similar. Is there anything interesting about your development environment?

    Cheers!

  • 2020-03-04 wuwu

    Hello, I'm using xampp local enviroment and Symfony app takes seconds(5-15) to load the first time. This happened with symfony skeleton when i barely had any code or libraries installed and the same happens with symfony demo application.

    Is this as it's suppose to be for development ?

  • 2020-03-04 weaverryan

    FYI, here is our upcoming Symfony 5 deep dive course :D https://symfonycasts.com/sc... - already mostly written

  • 2020-02-25 weaverryan

    Hey @Jack!

    Thanks for taking the time to offer more feedback - I appreciate it :).

    > I really miss these old tutorials which some would say were sort of rigid. It all began to change before knpuniveristy moved to symfoncasts and really started to gallop after it became official.

    This definitely wasn't on purpose. BUT, it is possible that I've gotten a little "looser" over he years on accident - I hear myself talk A LOT... and so hearing feedback is really useful. I know it's not easy, but do you have some specific examples? Bad jokes? Silly themes? The tone I have? It's (of course) hard to please everyone - and we generally get really nice feedback. BUT, it's always helpful to hear what people think who aren't so happy.

    > Every ambitious developer wants to say "I went through many SymfonyCasts tutorials. I gained vast knowledge".

    💯!

    > By the way, I remember when Fabien announced SymfonyCasts and a part of he note was: "... and (sometimes) bad jokes are now SymfonyCasts". I just feel like he thinks the same way I do and this "sometimes" word was just a political addon

    That IS possible :D

    > One other thing I can't understand is how do you make it Ryan. I mean, how a developer at your level, with your knowledge and experience can spent his time on topics under certain level. You are Symfony Core Team Member. You could snow all the SymfonyCasts users with your PHP/Symfony knowledge.

    I also love beginners! But I hear ya - I need to care for the beginners, but make sure that we keep pushing the boundary on new tech, new strategies, etc. I was already aware of that - but this thread is definitely re-enforcing that big time!

    Cheers!

  • 2020-02-24 Jack Kowalski

    This "childish" thing might have been too strong from me but honest however. I just feel I'm not taken seriously by the person teaching me. I really miss these old tutorials which some would say were sort of rigid. But they weren't. I felt like everyone knew their responsibilities - mine was to work hard and give my best, tutor's was to make it all clear and transfer as much knowledge as possible. It all began to change before knpuniveristy moved to symfoncasts and really started to gallop after it became official.
    Of course I understand the world is what it is these days and a great deal of people is just infantile but what we (Symfony community) do is bigger than some another pitful YouTube channel. And I don't say anyone forgot about these responsibilities but I say someone has... liberalized them and got trapped by modern dogma where seriously means boring. No one want's knpuniversity (yes, I still enter this inside the address bar, from sentiment) to be a place where we smile, joke, pat ourselves on the back but content level goes down. Every ambitious developer wants to say "I went through many SymfonyCasts tutorials. I gained vast knowledge".

    By the way, I remember when Fabien announced SymfonyCasts and a part of he note was: "... and (sometimes) bad jokes are now SymfonyCasts". I just feel like he thinks the same way I do and this "sometimes" word was just a political addon.
    One other thing I can't understand is how do you make it Ryan. I mean, how a developer at your level, with your knowledge and experience can spent his time on topics under certain level. You are Symfony Core Team Member. You could snow all the SymfonyCasts users with your PHP/Symfony knowledge.

  • 2020-02-24 weaverryan

    Hey @Jack & Lindar!

    I totally agree :). There are 2 things going on right now:

    1) Because Symfony 5 (new major release) is out, we need to update our "starting" tutorials to Symfony 5. That's the purpose of this tutorial - it's a maintenance process that we've done for every major Symfony version. Fortunately, updating these tutorials doesn't take up all of our time - they're quick to create.

    2) While updating these tutorials, we are also working on true "new" tutorials. And you mentioned some good ones Jack :)
    A) symfony kernel or symfony container or request-response flow We have an old (outdated) tutorial that shows this and I would LOVE to update it - one of my *favorite* tutorials ever. And actually, it would be a quick one to get out. I might see if I can mix this into the schedule soon...
    B) Where is the solid tutorial or design patterns tutorial You had to mention the design patterns tutorial - the bane of my existence :p. We have a few helping authors "not work out" for these. That's something I take responsibility for. We *are* actively working on the SOLID one. It's a simple topic - but so many places basically re-define them... and leave you still wondering "what it all means" in a real-world application. THAT is the hardest part with that tutorial. The examples will all be practical. We're working on this one. Design patterns will follow - we decided that it makes more sense to do SOLID (and probably object calisthenics) first, and then design patterns.

    You also mentioned:

    > Besides the lector being more and more childish every next tutorial
    > ...
    > Please consider ... more seriousness lector behavior

    Sorry about that! It's tough - watching technical tutorials can be *boring*, and we don't want that to be a reason why someone stops. We do get some feedback like this, but we also get way more feedback that people really like it. However, I realize that for some people, the jokes, etc can be distracting. If you have some specific situations or things that you don't like, I'd love to hear them. We can also get better :).

    By the way, as non-beginner users, if there are other tutorial topics (beyond the few that were already listed) that you'd like to see, let me know!

    Cheers!

  • 2020-02-24 Lindar

    I'd totally agree with that. For these stuff we have symfony documentation. I'd like to see more advanced topics.

  • 2020-02-23 Jack Kowalski

    What will this course be about? Composer install? Hello world route? Symfony server:start? Besides the lector being more and more childish every next tutorial also the content is getting more trivial. Where are really important considerations like symfony kernel or symfony container or request-response flow? Where is the solid tutorial or design patterns tutorial? These are really important topics that make a good developer. Otherwise we have this bunch of juniors everywhere that write unmaintable garbage code with controller, entity and a *Service class with 3000 lines that does everything. Please consider more ambitious content and more seriousness lector behavior.