> Symfony 5 >

Course Overview

Login to bookmark this course

Charming Development in Symfony 5

Unleash the power of Symfony 5: design your app, master bin/console tool, Twig, hit the web debug toolbar, and learn to create JSON APIs.

  • 10604 students
  • EN/ES Captions
  • EN/ES Script
  • Certificate of Completion

Your Guides

About this course

This tutorial also works great for Symfony 6!

What PHP libraries does this tutorial use?

// composer.json
{
    "require": {
        "php": "^7.3.0 || ^8.0.0",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "easycorp/easy-log-handler": "^1.0.7", // v1.0.9
        "sensio/framework-extra-bundle": "^6.0", // v6.2.1
        "symfony/asset": "5.0.*", // v5.0.11
        "symfony/console": "5.0.*", // v5.0.11
        "symfony/debug-bundle": "5.0.*", // v5.0.11
        "symfony/dotenv": "5.0.*", // v5.0.11
        "symfony/flex": "^1.3.1", // v1.21.6
        "symfony/framework-bundle": "5.0.*", // v5.0.11
        "symfony/monolog-bundle": "^3.0", // v3.5.0
        "symfony/profiler-pack": "*", // v1.0.5
        "symfony/routing": "5.1.*", // v5.1.11
        "symfony/twig-pack": "^1.0", // v1.0.1
        "symfony/var-dumper": "5.0.*", // v5.0.11
        "symfony/webpack-encore-bundle": "^1.7", // v1.8.0
        "symfony/yaml": "5.0.*" // v5.0.11
    },
    "require-dev": {
        "symfony/profiler-pack": "^1.0" // v1.0.5
    }
}

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

Next courses in the Symfony 5: The Fundamentals section of the Symfony 5 Track!

61 Comments

Sort By
Login or Register to join the conversation
Default user avatar Jack Kowalski 4 years ago

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.

5 | Reply |

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

2 | Reply |

Hey @Jack & Denis M.!

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!

4 | Reply |
Default user avatar Jack Kowalski weaverryan 4 years ago

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.

2 | Reply |

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.

4 | Reply |

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!

1 | Reply |

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!

3 | Reply |

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

| Reply |

I also detest the childish speaking style. He's presenting to programmers, not babies that need to be toilet trained.

-1 | Reply |

Hi Roman!

Yea, that's my childish speaking style :). I *am* sorry you don't like it - we have a lot of users and we *do* get this feedback a few times a year. We also get a lot of positive feedback that the light-hearted style makes it more fun to follow - it's tough to find a balance! Anyways, I appreciate the note - it *does* help us to *best* find that right balance.

Cheers!

1 | Reply |

I like light-hearted styles, but suggesting that a directory contains puppies is too much for a course for adult programmers.

| Reply |

Ok, fair enough ;).

| Reply |

I must confess that I really LOVE your childish speaking style :)

3 | Reply |

youve clearly not met many programmers :D :D :D most of us just use a bucket.

| Reply |
Oleksii avatar Oleksii 4 years ago

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

1 | Reply |
Default user avatar Christian Aigner 2 years ago

I am not using Docker, because on my Linux box Apache, MySQL and PHP are already installed.

In .env I have entered the correct information for DATABASE_URL.

For some reason the env var does not get exported.

symfony var:export --multiline reports:

export SYMFONY_DOCKER_ENV=
export SYMFONY_TUNNEL=
export SYMFONY_TUNNEL_ENV=

I received this error when I want to run: symfony console doctrine:database:create:

In ExceptionConverter.php line 103:

An exception occurred in the driver: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: Yes)

In Exception.php line 30:
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: Yes)

In Driver.php line 28:
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: Yes)

What could be the reason for this? And more importantly: How can I solve it?

| Reply |
Abelardo avatar Abelardo 2 years ago

Are you planning to release a course with ELK?

| Reply |

Hey AbelardoLG,

Thank you for your interest in SymfonyCasts tutorials!

About ELK - most probably the first course would be about ElasticSearch only - like 99%, and only then (later) we may consider covering ELK in a separate course in the future. We do want to release a course about ElasticSearch some day, moreover we use ES on SymfonyCasts website to provide a powerful search for our users. Unfortunately, we don't have certain plans yet, so I can't tell you when it might be released. So, no course about it in the nearest future, sorry, and thanks for understanding! Btw, you can track upcoming courses on this page: https://symfonycasts.com/co...

Cheers!

| Reply |

Thanks Victor!

I will regularly pay attention to that page

Best wishes!

| Reply |
Roger P. avatar Roger P. 2 years ago

The interface is in Spanish for me, even though I choose English.

| Reply |

Hey Roger P.

Thanks for informing us we're actively looking for a solution quickly. My apologies for any inconvenience.

| Reply |

Looks good now, I can select English. Thanks.

| Reply |
Ilya K. avatar Ilya K. 3 years ago edited

there

The description of the track says:

After this track, what will my level be?
...
You'll be able to use all of Symfony's major pieces - Doctrine, forms, security, etc - to build real web applications
...

But I haven't found any tutorials about forms in the courses of the track. Are there any? Thx.

| Reply |

Hey Ilya K.

You're correct, we didn't release a course related to forms for this Symfony5 track, but that's so because we released a real nice tutorial about forms in the Symfony4 track. You can give it a check here https://symfonycasts.com/sc...
The forms component haven't changed much since Symfony4, so you should be able to follow it up using Symfony5

Cheers!

2 | Reply |

Ilya K. hello there! in an attempt to answer a bit more straightforwardly your question, this track will leave you with a very basic, but robust and real-world-ready level of knowledge about working with SF, although it is indeed a basic introduction, it will give you everything you need to "start" building up SF web apps, if you want more complex processes, its recommended you finish other tracks AND practice a lot, but trust me, this track will, without doubt, get you started properly and successfully!.

also as Ilya K. said, go to the SF4 track and check the forms chapter, that will also add up to your knowledge.

1 | Reply |

Hey Jose!

Thank you sharing your thoughts on this topic! It may help others a lot as you say it from the perspective of user :)

Cheers!

1 | Reply |
Ilya K. avatar Ilya K. 3 years ago

Hi Ryan, First of all: Thank you very much the amazing course and especially your great performance as reader! A question a bit out of the scope: What CLI color schema do you use? Can you please share the name or maybe somehow the scheme file? Thanks in advance!

| Reply |

Hey Ilya K. ,

I know that in videos Ryan uses iTerm2 terminal for Mac OS, you can download it here for Mac: https://iterm2.com/ - though not sure if it's the default theme or not, maybe Ryan will tell a bit more :)

Cheers!

1 | Reply |

Hey victor !

Thanks for filling in the first details Victor :). I think most of my customizations at this point are coming from zsh with "Oh My Zsh" on top of it (I think I wasn't using that for THIS specific tutorial, but it's what I use now... and I tried to make it look similar to what I used before). I'm using the theme called "af-magic". I have a few other minor customizations, but I think af-magic and Oh My Zsh account for most of them. But if there is something else I can help share, I'd be happy to!

Cheers!

1 | Reply |
Ilya K. avatar Ilya K. weaverryan 3 years ago edited

weaverryan weaverryan

Thank you very much guys!

| Reply |

Hello there its been a very long while.

I have a question, im trying to get a multiple choice field from a different entity than the main form entity to work.

I have more than 1 table in my database, and the main table, lets call it "person" requires the form rendering includes several multiple options from different entities than its own. lets just add 2 for example, they are "language" and "skills", where Language its its own entity, and can have several languages in it, and skills is the same, so when you add a new person, the form should render the "languages" and "skills" from its respective tables, I am not using a relational entity, as this is a quick fix, so I decided to go for a CSV format, so what I want is to get those values, print them as multiple choices(checkboxes) and when I add a new "person", it gets the values selected, and adds them to its respective table, thats no problem, the issue is the form printing.

I'm doing this.

adding the entity for each


use App\Entity\Language;
use App\Entity\Skill;

and in the PersonType for the forms

in the $builder I have this


->add('language', EntityType::class, [
                'class' => Language::class,
                'choice_label' => 'language',
                'multiple' => true,
                'expanded' => true,
            ])

yet it keeps erroring that it cant find that label either, I get why, as in "person" the language field is rendered as "person_language" not as "language" but if I change it, it then tells me it cant find the label in the "Language" class.

is there a way to solve this issue without setting a One to Many relationship? (one person can have many languages)

Cheers,

| Reply |

Hey jlchafardet!

Nice to hear from you :). I'll answer each comment independently.

In this situation, when it comes to building this EntityType, the form system/Doctrine doesn't care at all that you're building a form for your Person entity. What I mean is, you could copy and paste the EntityType field into any form and it should always do the same thing: render a select element for all the Language in the database (or, check boxes in your case).

Let's break down the pieces of it a little bit. First, the choice_label. This is the property on the Language class that should be used to render each Language. So, for example, if your Language class has a "name" property (e.g. English, Spanish, etc), then you should set this to "name". You can also remove this option entirely and add a public function __toString() method to your Language class and that will be called when rendering each check box.

Second, the language that is the first argument to the add function (->add('language'...) IS the one piece that is related to this being a form for a Person entity. This is basically the property that the selected Language objects (there will be multiple since you have made this multiple => true will be set onto. For example, you said:

in "person" the language field is rendered as "person_language"

I believe that this is probably (based in part by your next comment) a relationship - like you have Person entity with a OneToMany relationship to some PersonLanguage entity. For simplicity of understanding how the form works, I'm going to simplify this to: You have a ManyToMany relationship from Person to Language. Let's assume that this relationship is defined on a property in Person called "personLanguages". If so, THIS (code>personLanguages) is what you should use for the first argument to your add()` method. When the user selects, for example, 2 language check boxes and submits, this will cause those 2 Language objects to be set onto the PersonLanguages property.

This may not fully answer your question, but hopefully it will get things rolling forward :).

Cheers!

1 | Reply |

@weaverryan thanks a lot for your answer, and same ill reply to your replies independently too :D

yeah for the momment I got the EntityType to work.


 ->add('languages', EntityType::class, [
                'class' => Language::class,
                'choice_label' => 'language',
                'multiple' => true,
                'empty_data' => [],
            ])

it actually allowed me to print the widget properly as I wanted, dunno why I had so much trouble before haha, maybe because I had relations, now I removed them, as to get the MVP ready to present tomorrow (its Sunday 10 pm, and I most likely will work until I turn it over at mid day tomorrow, so ill just store an array on a field for person with the id's of those related tables, and do the troublesome thing of having a query first, to get the name of the languages(skills, etc etc) that are actually associated with each Person.

right now as all I care about is to "show" the mvp progress, it will lack some features, but the important ones, will work, allowing my boss to see that the time spent on it wasnt wasted :D.

| Reply |

Hey jlchafardet!

Sorry for the slow reply - had some time off last week! Nice work getting this to render :). Regardless of relationships, this setup will cause the "languages" property on your Person class to be set to an array of Language *objects*. If you have a ManyToMany from Person to Language (stored on a property called languages) then everything should actually save just fine.

Cheers!

1 | Reply |

thanks a lot :D yeah MtM for the tables languages and skills was the way to go, I can add skills or languages without having to add a person, and when I add a person I can choose from the multiple field those languages, and it saves the relationships just fine.

what im facing now is i have a comments table that was asked of me last week, it should be a one to many relationship, where 1 person can have many comments,, and one comment can only belong to a 1 person, so my question here is, should I add it through person or through comments when using the cli tool ?

| Reply |

Hey jlchafardet!

Sorry for the slow reply again - I had a family situation come up.

> so my question here is, should I add it through person or through comments when using the cli tool

The answer, fortunately, is: it doesn't matter! You can do either and the make:entity command will help generate the exact same code. So use whichever way "fits" in your head better (e.g. "it makes more sense to me to think about a Person having many Comments, so I'll edit the Person entity and add a comments property) - but it will make zero difference in the final code.

Cheers!

1 | Reply |

Thanks a lot, I hope your family is ok and everything is in order now.

yeah I noticed that it really didnt matter, as I tried it both ways and worked the same, the only thing I needed was to remove the "Person" value from the "skill" TormType and by passing the "Person" object to the Skill add/edit form, it adds/edits/removes skills from said person.

its amazing indeed, a tad out of the box, but indeed works in whichever direction I do it, so thanks a lot for your guidance, I appreciate it a lot!

1 | Reply |

in the case of having to use relationships, should the Many to One be on the other tables and not Person?
or if I go with One to Many, where should that bunch of relationships go? in Person?

I'm not quite experienced with this part of doctrine, so let me expalin a bit

Person is the main table, then we have "language", "skills", "whatever1" and "whatever xxx" tables, person can have as many of "the other tables records associated to a Person record", but not the other way around. although a reverse search is not bad, its not what I want, all I want is, when I have to add a new "person" into the database, I want to be able to choose from multiple selections, however it might come to be, the required choices from the other entities, but not the other way around.

so if I add a person, I need to be able (but not required to) select values from the multiple choice lists of the data from the other tables, but I MUST be able to add data to the other tables without affecting the table Person whatsoever at all.

| Reply |

Hi again jlchafardet!

The ManyToOne should is the only side of the relationship that is required, and that should always go on the entity that will hold the foreign key (e.g. person_id) in the database. In all of your examples, this ManyToOne would go in the other tables - like Language, Skill, etc. Why? For example, you could imagine that you have a Skill database table with a "description" column and a person_id column to link it back to the person. (As a side note... not to confuse things... but it needs to be said: Language might actually be a ManyToMany relationship... because you might want to have a simple language table that lists 10 languages... then you would have a ManyToMany to person - Doctrine would create a join table - like person_languagae - to store that, but there wouldn't be an actual PersonLanguage entity).

Anyways, the other side of the relationship - the OneToMany - is optional - and would live on Person. There is no real downside to adding this: it gives you a bit more power (e.g. you could say $person->getSkills() to loop over the related Skill objects).

Finally, I'd say this: use php bin/console make:entity from MakerBundle. This will walk you through the process (wizard style) for creating your relationships, helping you choose the correct type. It also maps both sides of the relationship automatically so that you don't have to.

Good luck!

1 | Reply |

weaverryan hey! thanks for taking the time to reply to my questions.

I think I will go with ManyToMany on most of the auxiliary tables, although there will be 2 tables that will not contain a list of values that can be related to Person, but records, like comments.

Language, Skills, will be very likely ManyToMany, as they both work in the same way, independent data that should not be repeated, that needs to be linked with one another, a Person can already know 1 or more Languages, and Skills, but they can also, learn more than 1 Language, and also more than 1 Skill later on, so having skills already on that table, could allow me, later on to do something like $skills->getPerson or whatever, if I want to see how many people I've got that know a specific skill or language.

| Reply |

Hey jlchafardet!

Ok! It sounds like you have a plan - let me know if you hit any "bumps" along the way :).

Cheers!

1 | Reply |
Helmis D. avatar Helmis D. 4 years ago

I think there is a bug in the track, all courses are marked as 0% complete.

http://prntscr.com/tt8krh

| Reply |

Hi Helmis D.!

Hmm, I see that! I just checked with my account, and I *do* see progress on these courses. Have you been watching the videos? Or just reading the scripts? You need to watch to a certain point in the videos to get each marked as completed. If you *previously* had part of these courses completed and now it's zero, then let me know - something definitely went wrong (unless you decided to "leave" the course, which resets things).

Cheers!

1 | Reply |

I see ... I think it's because I wasn't connected that it didn't work ...
I propose a small improvement :)
It would be necessary to create a system which takes into account the user not connected and then merge the result after the successful connection, as we do with the shopping cart in the online sales sites or tell the user that it is necessary that you have to log in to see his progress.

Cheers!

| Reply |

Hey Helmis D.!

> I propose a small improvement :)
> It would be necessary to create a system which takes into account the user not connected and then merge the result after the successful > connection

I agree completely! But, the system *should* already work this way - it's a feature we've had for a long time. However, I'm going to double-check and make sure that a bug didn't sneak in. As you're watching *anonymously*, the finished chapter ids are stored in the session. On authentication, they are merged into your user account. Just in case it matters, do you remember how you ultimately authenticated? Did you register for a new account? Login with a normal password? Or connect via a social account?

Anyways, sorry about the trouble - that's annoying!

Cheers!

| Reply |

I see... In fact i am not connected at all, the problem is that i do not see my progress when I am in anynome mode.
As you can see in this print screen http://prntscr.com/tv14yp i finished 5 chapter and in the tracking after many refresh of the page still give me 0% progress... http://prntscr.com/tv189w

| Reply |

Ah.... of course! I should have thought of that. Yes, I bet there is a bug where we are *storing* the progress of an anonymous user, but not actually using that to correctly show the % completed. I'll open an issue about that right now - thanks for pointing that out!

Thanks!

| Reply |
Default user avatar Ivan 4 years ago edited

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<br />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)

| Reply |

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!

| Reply |

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.

| Reply |

Delete comment?

Share this comment

astronaut with balloons in space

"Houston: no signs of life"
Start the conversation!