Symfony 4 for beginners | Aloui Mohamed Habib | Skillshare
Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
65 Lessons (5h 24m) View My Notes
    • 1. Environment Setup

      1:08
    • 2. Download Symfony

      2:38
    • 3. Create new Symfony App

      3:25
    • 4. Folders Tour

      2:55
    • 5. Create first controller

      6:47
    • 6. Boot-up Symfony App

      3:05
    • 7. Twig the template engine

      8:09
    • 8. Explore routing

      5:23
    • 9. Meet Doctrine

      5:40
    • 10. Configure Doctrine

      2:47
    • 11. Create First Entity

      6:58
    • 12. ORM & Entities

      4:57
    • 13. The Migration

      1:21
    • 14. Save records to database

      5:55
    • 15. How to Revert migration ?

      3:30
    • 16. Update an Entity

      5:56
    • 17. How to Revert migration ?

      3:19
    • 18. Fetch single record from database

      6:32
    • 19. Fetch multiple records from database

      5:28
    • 20. The Query Builder

      5:14
    • 21. Update database record

      8:44
    • 22. Delete database record

      5:18
    • 23. Doctrine relationship Introduction

      2:17
    • 24. Explaining relations on board

      4:40
    • 25. Update entities with relations

      20:52
    • 26. 40 relations in actions

      4:40
    • 27. Form in Symfony 4

      0:45
    • 28. Install form component

      0:54
    • 29. Create a First Form

      3:19
    • 30. Create Form based on an Entity

      1:35
    • 31. Dispaly form in twig template

      3:50
    • 32. Styling Form

      3:40
    • 33. Twig extending feature

      4:34
    • 34. Create a Form manually using FormBuilder

      4:21
    • 35. Customize form rendering

      2:45
    • 36. Custom Form Label

      2:51
    • 37. Handle form submission

      6:22
    • 38. Store submission to database

      3:58
    • 39. Form validation

      5:13
    • 40. Form validation: custom error message

      0:47
    • 41. Bootstrap template for the form

      2:12
    • 42. Default data into the Form

      3:25
    • 43. Let's start practicing

      1:45
    • 44. Create the UI skeleton

      7:00
    • 45. Load assets using "Asset"

      1:30
    • 46. Setup Encore

      3:27
    • 47. Encore in action

      3:21
    • 48. Enable Sass using Webpack

      2:04
    • 49. Working on the UI - EP I

      18:55
    • 50. Working on the UI - EP II

      8:56
    • 51. Flash messages

      3:49
    • 52. Setup Bootstrap accordion

      4:58
    • 53. Fake data with Fixutres

      8:13
    • 54. Execute fixtures

      1:40
    • 55. Deal with Accordion dynamic index

      1:44
    • 56. Add action buttons

      17:37
    • 57. Implement CRUD Operations

      6:11
    • 58. Update: Close a todo

      5:50
    • 59. Events in Symfony

      3:26
    • 60. Events explained

      3:47
    • 61. The event listener vs event subscriber

      1:18
    • 62. The event listener

      5:17
    • 63. The event subscriber

      5:56
    • 64. Docrtrine event

      5:55
    • 65. Create custom event

      12:46

About This Class

Symfony 4 is a powerful PHP framework that would let you create not only websites but great web applications, APIs or mobile backends.

It's latest version is the most powerful, yet simplest to use for developers. If you want to get started with Symfony , this is the best place you could get.

We'll go through each single task step by step, you will code along with me. I'd explain every detail of how things work, and how things should be done.

I'll even leave some scene with error uncut that you can see and experience a real world coding example and how the journey is!

At the end of this course you will complete a fully working, real world application.

The recommended development environment is Linux for the sake of speed and optimization for developer, but if you are on Windows or MacOs no worries. I won't be using any tool or package that could restrict you from taking this course if you are on an another environment.

The course starts with introduction.

Then we'll move on and install the framework using official documentation and guides.

Next section is centered around Controllers, Routes and Twig templating engine. You will learn how to create a backbone of your application and how to render HTML together with data using Twig. We will also see how we can install and manage assets, like CSS & JavaScript, by installing Bootstrap using npm ( You can use Yarn if you are comfortable with ).

After that, will touch databases and the excellent Doctrine ORM. You will learn how you can create simple PHP objects as a representation of a table rows. You will learn about database migrations - an easy way of managing your database schema changes. This section will also show you how to quickly fetch, modify and delete data from the database.

And we end up doing some Front-End work updating and customizing the User Interface.

Who this course is for:

  • PHP developers that do not know any framework

  • Developers with some knowledge of other PHP frameworks

  • Developers that need and want to pick-up Symfony fast with straight to the point course

Transcripts

1. Environment Setup: before start making our hands dirty. I would like to present you what tools that we are going to be using. So first of all, I will be using until a J as a my i d. Why intelligent? Because simply it does support fully the symphony framework. And also it's pretty Hamby, in term, off to complete and that kind of stuff Sure, you are free to use any other idea that you would feel comfortable weight on that offer the plots on Also be using a terminal. You are free to use any other terminal. I'm using TLX with my Z a Z s H. Plaza Aziz. A team was ignored. Terminal and I will be using a peach. Be. The version is seven. And also it's good practice to have the latest version. That's your project will be still updated no matter what the version is updated. The number watch beach be Version is out and would be using symphony for All right. Okay, everything set up. Let's go ahead and start making our hands dirty 2. Download Symfony: in today's episode would be installing Symphony and to do that it's very, very simple. Simply, we had Teoh the symphony dot com official website and clicking on the download button would be landing into the space age. The space actually present avarice information. First of all, we should we see, Would you see that they present the future conferences for symphony since your lab And right here, this is the pilot we are interested in and which is then we'll own the symphony client. What is self? Any clients and hopefully they did introduce it s o they help you. So this is it. So it does help you to create symphony application provides a local issue tippy Web server generi to TLS certificate. You check the security vulnerability seamlessly integrate with some finical out must have to develop into Okay, this is three big and long description for what is actually a symphony client. It's simply a tool generated by symphony by since your labs. Actually that help you execute various tasks is one of that is to download. This creates a new symphony project. So right here we have a very spot form Windows Mac OS on Lennox for Windows, we have a standard exit file, but you simply don't lose file executed, and you will have a symphony in the command line ready to be executed and that help you download and run projects for back Wes and Lennox based Linux systems. You want to be in whatever else we have to download this file, which is installer under on. And yeah, so just to run this command and we'll do the rest for you, and there is the smallest directions to configure it. So I really don't that. But I'd like to show you what's going on there. So I take it, like, a couple of seconds to finish the panic on your connection speed. Okay, The next thing is the configuration system. So there you go. Hopefully does finish. In my case, I'm in linen. So as I said this, actually, this part off this video is for Linux based systems. We need to export Theis Symphony into our path that we could be able to do symphony like this. So our command line would be able to read symphony as a command and ready to install a new version on dollar new vision of symphony from this command. The next episode was he have to create a new symphony project 3. Create new Symfony App: in the previous episode, we did down Loo the installer from the symphony website and we're all ready to start doing our things. So first off, we'll make sure that symphony is accessible from your command line. The next think we head back to symphony website on the school a bit down where we do foreign the curating symphony application. Right here we have two tabs one for this table Latest release, which is 4.2 for now and the other one is for the LTs for 3.4 that we won't be working with these videos. I will be focusing on the 4.2 and by the way, there is big difference between the two and a leave you a link describing the difference between the 3.4 and the fourth version of symphony. Okay, so right here we have two options. If you are building a traditional web up, we could use this command and elsewhere A few building There is a timeline if you prefer composed, composed, great eso would like also to create like the project using the symphony of the composer's and that second option if you are building a Micro Service Council application or in a P I you simply do symphony New project. What is the difference between the two? So the difference is actually that we have a flag with the dash dash full, which means that we are going to have a full version off Symphony 4.2, which actually will be loaded with a bunch off. Oh, actually, of a bunch off old modules on component that will be needing. So, for example, when we do generate a symphony were this command we want to have? The dump won't have the doctrine. We won't have the plenty, for example, won't have the routing, etcetera, the online routing, validation routing story. So using the fall, we ensure that we'll have the whole loaded package ready to start plane on doing things with it directly without bothering adding any like needed extension. And right here, eyes mansion. They said that if you are born again micro services So, for example, if you're working with an I p I that return and Jason object, you won't need the dumper, for example, or you won't need an X component that does not interfere with the a P. I Let's just go ahead and use this minimalistic that you get the chance to see how that we could added more component to our application. So could be this command line and back to our terminal. And make sure the symphonies ready. Okay, then Simply based vast commitment on right here. What this command will do. So we have symphony and new on right here. It will generate a folder that containing all the files off our symphony application. So right here I will call it to you to May to do and simple as that and hit, enter and from the composer will take the hand and start doing the magic downloading all the files and Soling everything needed. And after a couple of three minutes, everything will be ready to start working with symphony. So we stop here and we'll be back when everything is ready in the next video. That would be discovering a bit a bit, which is symphony, how things are and all that kind of stuff 4. Folders Tour: welcome back to this new video, so go ahead and open your project into I d and start discovering what's going on there. So, first of all, we have this bin folder and it does contain a single five called Council. Without any extension. It's actually a peach be as my i d show. So if we open it, it's a PHP file. We have, ah, very since direction. And the main purpose of this is to execute many type off commands at the lowest to do many type off actions like generating routing, generating controllers, emptying of the cash, updating the database using doctor, and that would go ahead and see it later. And yeah, this kind off tasks that we need to do convict is a folder for configuration as it the name sad. And it does have a deaf older that's containing routing for the deaf environment. And then we have a test also for folder for testing our work, using the unit tests or whatever testing you would like to use. We have the cash Yamil that containing configuration for the cash. We have also the framework of file a Jamel that is containing some other configuration would be back to these later. We have the routing, as the name says offer routing stuff for defying the route, etcetera and closing the pack ages. But yep, so we have. Ah, was second. We have bootstrapped that is used by composer to down things and or to load that kind of stuff. Have the bundles routes for routings again and services to define services. The public folder for public assets. JavaScript, CSS images, etcetera. We have also the SSE, which is the main fuller off our application. Continue controllers. The View, the Colonel Lot Aedes. It's updated comparing to the 3.23 point four, but we don't really care, since we are planning Teoh work with 4.2 Symphony with Fire folder for the cash on Lives benders containing the composer a PSR symphony. So these are like the micro must have a component that I love symphony to be booted. So symphonies treated in a way to be like a micro up eso. Basically, we have what we call flags that would be responsible for adding as much composers or component story as we need for our work and yeah, so something is more like micro framework than the big, ah, huge framework that we have a three point for version on. We are going a bit closer to Larible type of things. Okay. And the next episode we start discovering how to create a very first controller. 5. Create first controller: and Symphony 4.2. It's a very different the way how to deal with things. So have experience with 3.23 point four story. It was like a notion of Vandals and bundle containing files and controlled cetera. But here it's slightly different. It's actually too much different since we talk about a micro, uh, framework. So security controller, it's simply going to SRC come trollers. And right there we could click right and had to new and creating new file. And you could call it Hello, You two meet. Oh, you to me. So you do me controller like that dot PHP Don't forget the extension. I did it. And right here we start typing our PHP code. So first of all, starting by defying the name space. But in my case, it's app ab slash controller. Actually, just make sure that everything is in the right case. Controller. All right? And right here I started finding class. We've name exactly you do me control. Oh, that extends from extend the abstract controller. That would give us access to plenty off tools that will need Teoh elaborate our application . So just make sure that you are importing the abstract controller from the framework bounded not from any other package. And right here we could start doing things. So bundles or controllers is Bay, a composer from various building blocks, which are methods or functions. So let's go ahead and created 1st 1 functions. Call it inducts, for example, in the previous three point for the room that we have to fix this with index dot action. It's no more that case, so it's simply and backs like that, and we could do new response or echo open toe, whatever. So this is how to create control or insane. Funny 4.2. This is actually the first approach, the manual approach. And also we have another approach which is through the council right here. So let's go ahead and open the council. Okay, So clearing this and as you see him under the folder off my project, and I will do PH. B. Ben Council, the file that we so in the previous video and I will do make dot controller and look what happened. It just said there is no commander finding in the make name space, and this is normal because we don't have this maker off controller installed into our minimal micro package. To fix this, we need to go back to what we call symphony recipes website. That's containing list off back ages that you could added that you could actually plug into your project and make it having extra features. So right here I will search for make right here. We do see that we have this symphony make bundle maker Bandel, and it's official. This one is contribute is from contributors. Viscera specials contribute by someone from the community. So we go to this official rep. Oh, it's rece I p off sort of that actually hit back age details on from here. We could just simply grab this. And as you may see, this is the dude who is maintaining symphony. Who is Fabian? OK, copy that. Back to composers. Make sure that you are under the folder off the project and hit anta. So it take some moments that don't load the package. Install it and everything will be ready. So right here What is humbling? This is a tool or like it'll from symphony central objects called the flags is responsible off doing everything and let me just let that download take a time and let's search for flags that you could discover what's going on there. 4.2. So this is a sauce flexor. Symphony flags automate the most common tasks off symphony applications, like installing and removing bundlers and other composer dependencies. So simple as that composer off Symphony did lead on the flags Teoh to do to manage everything in term, off components. And yeah, so I Also they said that symphony flags work for 3.3 and the higher so starting from 4.0 flags should be used by default because we start talking about a micro application instead off a framework. Okay, so it does say that everything is ready now. It could go just back to the history and make come true love. Okay, composer, I need also to have another one, which is composer, which is annotation, actually. So it's say that missing back age to use components or make control, so simply copy this based it. Give it second that download itself and would be ready to creating our first controller using the terminal. So it's Salling things. Everything should be ready. So we have a package and thought we have doctrine. We have our most of them are doctrines. So now if you go back to hit controller Yeah. Welcome back. Let me just clean this and you could see it properly. It does show Chose a name for your control or glass, for example. Grumpy puppy controller. Okay, let's call this you do mate controller. And hopefully we won't bet Get confused between by the old one that we created and hit Enter And I said that because it's really exist, so you could just remove it manually and back to our i d We could just remove this folder or this control, actually, and we could run that command again without any problem. Timeto and again, you would amaze controller without with small Oh, pay attention. Enter and everything should be fine. No, If you go back to our i d, we will notice that we have a new unity controller with this. What we call em line routing. So now if you go to our application on the hit slash shooting me, we'll be seeing this message. But first off, what we need to boot up our application and this will be the purpose off the next episode 6. Boot-up Symfony App: Hello and welcome back to this new episode. So previously we did install Symphony. We configured our environment. We do. We did too much things we created even first controller. But we still don't say any output in the browser. We still cannot let Sai navigate our application and this video this absurd. This is the purpose off this what? So to boot up symphony there is two way. The first way is to use a classic server where the engine eggs were Apache. Whatever. You just need to host your application and on the server even locally owned deployed. Hosting the 2nd 1 which is for development purpose, is to use a local server Web server that came with symphony and you could install to throw through the crispies off recipes of seven Penny by searching for server. And you couldn't told symphony Web server bundles. And if you do remember the previous video, we didn't stall the invitation. And actually, annotation is bundle off Vandals. This collection off module that came to gather to allow symphony to execute many functionalities. So now I have the two options. Is that whether to host it under any server even and you're looking machine or most server or just use this built in server and in my case, to speed up things for development purpose. And generally this will be the case. I will be using this bullet in server so had back to our council. And I will do symphony server dot start and this will boot up everything to us. So it say that, OK, Web server listening on this address. And it does show the PHP virtual that we are on. So let me just copy this back to browser. And if I open this, I will get this Welcome to Symphony 4.28 Your application is ready. You can start working on it. Great. So does show also the path that is located under back to our I d. And we do remember that we have this would, you know, make controllers should be accessible through this slash you too. May and I made a mistake in the previous video. I said this is in line. Routing is actually an invitation routing. So, Mike, my apologies for that. So right here, I'm just copy this and right here in the browser, Ural, I just typed you to me on. I do get this output. It's adjacent object Because we have here this daughter, Jason, and this Jason is actually irritated or extend from the abstract controller right here. So if I control click on it, it does take me to the controller trade that is actually under the abstract controller. That does return Jason response. Okay, so that was how we do boot up our application. 7. Twig the template engine: hello and welcome back to this new episode. So today's video would be about a twig. What is to egg? It's pretty simple. So first of all, let me just Google er to get brief definition of it. They said that twig is a template engine. Let me that make this slightly bigger. So Twig is a template engine for PHP programming language. It's a tax oriented from ninja and Django template, and it's open source product places that under the B is the lessons and maintained by, for example, Marcy And another term, it's contained by sensual up, which is the form better off symphony off, like people in the community behind Symphony. Okay, no, if we do, if we jump actually to this first linked to adult Symphony, we do find a really large documentation that could help us through our application and how to manipulate and have to use a symphony twig or to wake engine for symphony. And right now, let's go ahead and see inside our application how to introduce this to again, how actually use it. So, first of all, I would like to create a new method so ago to greet function on dial. Call this function. Let's go. For example, Log in or to do for now. And this method won't take anything home of function. You could court right here. I would like to add an annotation which is route thought. Selling symphony too. Road this when I do or to execute this function or this method when I do, for example to do right on the second part of meat, I could name this to to do route, for example. Actually right here. Sorry, It must be a couple. No single quote. Okay, let's school these students right here. Everything should be fine now. Because if I copy this and I jumped to the browser where I have my website loaded and they hit two though, groups like something went wrong. So the bodies found. But there is no return state at the ad. Doesn't said here the controller must return something, which is a response. Okay, So back to our method. And right here I could simply do do a lot of this or dollar this and get the render method that is also omitted from the abstract control that allow us to. Hopefully there is documentation, but there is No, but actually, it's a low as too passive you, which is a file to be a twig file, and listo a write off options or part of me that could be displayed inside this view. So let me just close this and back to this file to this method. Actually, Andi, I could do simply pointed to any specific term play that I would like to have. So now let's go ahead and create this fine and decorated. We need to placed under a specific folder under the root of our applications. So this father will be name. It's, um, plight as a convention right here, Term lights and inside it will re creating another folder, for example, Let me call it you. To me that would be referring to control or contacts. So it's a good practice re to have them configured because imagine, you could have like, 20 or 40 or 50 templates, so it's good idea to separate them by contacts on really inside it. I would create a new file, and I call it to do dot html dot twig, and this is the conventional from a mingling symphony. Okay, a matter that and Now if I just create any dummy tax that could render it to the controller on right here, I have to point this method to load this file and to do that's pretty simple. First, awful Symphony will load or search for this template under the stump light right here. So there's no need to mention the template folder directly right here to do the next. The correct thing is to point it out to you dummies Off symphony. We can get in a template directly, and I do Sorry, that must be typing here under you to may slash. Okay, Mike, I d still did not pick up, but to do that html dull twig. And don't forget to other the return right here to avoid any problem and still not cannot display that. But anyway, so you today back to the browser's refresh, and you cannot use runner method into if template, component or twig are not available. Try running composer Twig Bandel, and this is what I was trying to show you that we still need to install this component to be able to run symphony twig or to a great symphony. So to do that, I have back to city you to me to do. And right here I have to run this command again that I could get that. Ah, that's a new swig component installed into my obligation. I'll be able to load and to Teoh render these templates. So let's give a second that it does finish. So again it doesn't stole twig to accept money to Enbridge. Tweak. Everything is fine now It does. Also, some follow may have been created. A rabbit configure new pack age Please review it and commit them and everything should be fine. Now if I do refreshed, I do have that message. Laura MIPs Um and it's directly from my HTML tick. My estimate? A guess. Great. So now what about passing like a dynamic data? So let's imagine we'd like to say hello or good morning. Good morning, Mr. Or Madam, Good morning. Just simple. For example, Muhammad, I would like to pass this Mohammed to be dynamic, so to do that's pretty simply at with Symphony. It's simply by passing Gle binding perimeter from the controller animist. Call its name, and the next thing he's inside the control or right here, and I'll be passing it. And right, This is the second perimeter that you could pass through this render method on. I will be setting this to whatever I would like to pass. So right here If I died that let me just refer that that could see the changes. Hello, Ali. Mohammed. Ah, Louis Mohammed. Hobby Ali. Right now if I do refresh, I do see that I have. Good morning, Mohammed. Habib Ali. Great. The next thing why no. To pass a dynamic name. Stayed off hard, cooler dame right here. To do that is yet pretty simple again. I will be updating this route and the state of Slash to do him simply. I would like to pass in name right here. Okay, so and right here in the part A meter section of this to do I will do the large name right on day could type of to string If I want to guarantee that it would be a name on it. I will do basset in state of this static and ready If new refresh head would be crushed because I don't have this to do available. But if I do slash Mohammed all the way, I could get my name despite correctly. If I do, you do me a low people, whatever. You won't just get displayed correctly. So that waas twig and how to integrate it into our control or yet more to come with way because we started, we would be manipulating more data dynamically and display full loop with such what? So yeah, stay tuned and see you next up, so 8. Explore routing: before going further, I would like to talk a bit about watching what is routing and how does it work in symphony . So right here we did use one of the types that symphony allow us to use in grouting how to point calls or direct calls to a specific controller to specific methods right here. So everything is done inside the colonel off Symphony. And to get a bit more information, I would like to jump to official website again off symphony Andi, especially the tag off routing. So make sure that we are under the 4.2 version and we those speak about routing. So first of all, to have routing, we must have this annotation and stood. And we did already that elsewhere it won't work and we will have that ugly read every message or Chris Chri So also there is four types off routing or the way to define routing and symphony. The 1st 1 is annotation which is in the line routing right here, as we did for our unity controller, which is defining the utter out, using this as a key word and defining the path and assigning name that we could use this inside a twig file to director Chris dealing directly to this method. Okay, well came to this later. The second who the other type is the M will fire, and this is done through the conflict around the Thiemo, and it's pretty simple. So let's go ahead and explain this first full right here and we explain that in our project . So we simply defining name that it's meant it's like could be random. It must not be duplicated. Must not be existing are the same or again in this, um Oh file on the front of the path, which is a slasher blog's there and act slash two DUIs wherever and assigned to a specific controller right here. And there is plenty more options that we will see them in the future episodes. Also, there is another type which is XML pretty verbose and pretty of taxed for just single route . So I'm not a big fan of this, and right here we have also a PHP version off it. When we do create route Ph. B. And we do define things kind of San tax, I start by dollar route that he is actually routing configuration from the symphony component. And we do added, First of all, it's the path. It's the name sorry than the path. Then we assigned the controller responsible off it and the method that would be handling that. So there was the four type that we could define route in Symphony now. Okay, there is also plant if options right here. So, as I said, you could extend this for much more options and possibilities. We could utter the E 1918 n for translations you get at a prefect says you could other the Wilt card requirement. Imagine the blood list or the block route with contain a paginated so you could added pagination to force the type to be a number, not any Don't don't accept any like, ah, sluggish contempt instead of the number of others. Always blunt plant if options and the documentations Pretty simple. Explain this and we'll be seeing this life example by example. Okay, now let's go ahead and update our routing from this online argumentation Teoh config using GMO five, which is routes dot yum Oh, so right here we have an example to fashion or facility. Thinks so. Start by doing blood as a name. Okay, Andi, please. Here pay attention to the indentation because if you do not respect and attention, then nothing will work and you will run into trouble. So first of all, I have to define the path simple as that. So you could define home. Could find i d whatever. But there is no, uh, quotes. And the next perimeter, this is must be the controller and control. We must type its name space. I started my up controller slash backslash and it must be you to me controller by attention to the county case. And here we pointed to what method would be handling. So first of all, we must be sure that this is the correct name space. So we have up control you to me, controller. Correct. And we have this index thought index method that would be humbling this back to our browser . And let me just refresh the page on this Slash to dio on there is no okay, we have just removed that to the receipt A Vega. So we have message. Welcome to new controller SFC and that kind of stuff and the, um Oh, a routing is working properly. So there was a brief intro to routing And how does it work? And the favorites types 9. Meet Doctrine: and this episode would be talking about doctrine. So what is Doctor in its document? Relation, Alarm Apple and two again, thanks for the symphony community. In the official upside, there is breathed great definition introduction to what is doctor and how to do and how to work with it. So first of all, they said, that symphony does not provide a component work with the database, but it does provide a tight integration with third part library color doctrine on the When it clicking onto this link, we will be redirected to a website specific for doctoring and does present. What is Doctor and talk about various tools and how to do doctrine have todo careerist settle So Deduction Project is, ah, home off to several PHP libraries. Primary Folkestone databases storage and object mapper Mapping the core project are the object relation mapper, or M, and the database Abstract layer D B A. L. It wilts upon Okay, so plenty of options. Plenty off documentation is here the annotation, the cash decoding, the collections of common, the migration. We have things about my sequel Things for Mongol, Be things who for sequel Eyes that such for us so everything is there. What's interesting for us in this episode is how to configure doctor in tow, work with some funny So installing the doctrine first installed doctrine, doctrine support very or impact as well as market maker bound A which will generate some coat. Okay, so composer requires symphony or am pack starting by calling or executing this command right here. Let me just open new criminal off my fuller so see day, you too, may to do. And right here I will execute composer, require symphony or AM pack. And the next one is composer require this maker and we if you'd remember we did install this in the previous episodes when we needed to generate a new controller. So back to a this composer give it second that those finish and we could go, Let's read configuration. So So the database connection information eases told us an environment variable. Call a database. You are so back to our i d. And if you remember, we have in adult and the file, which is this one right and does contain old environment variables for our settings. So again, back to Vista, commendation is saying that the database connection is toe database euro for development. You can find on customized this inside dot I am they. So right here. As you may notice, by installing this package, it get updated and insert this block directly into this Dr in Dr Ian Bandel and for my describe it. And there's a link to this full description. And Harry's the database. Ural work. But we was talking about seconds ago. Okay, First of all, let me just set up this to work well with my current set. So my DB password will be password simple as that. I'm working on my machine, so there's no trouble to do any of that. Oh, to computer to have, like, special special password etcetera. So the next thing is this to define the database name on all the cooler to you To me. Symphony. Okay. Simple as that. And that's it. The next thing is executing this command line. All this command story. So it's ph B been consul doctoring database. Create on this will actually take this as per meters to connect to the database, and it will be generating the database name which is due to me that symphony or you to me symphony so back again to the council on Just do all images. Copy that for to speed up things a k PHP Been console, doctor and a base hit and hit. Enter and look what happened here. It does Said that access denied using the DB user because I forget to update this DB user instead of the abuser I'll be typing wrote and let me clean this run. It began and created database and pretty quick, right? Okay. Now, to verify that everything is fine, I would like to connect to pseudo my sequel on DA bus, The past word. And right here if I do show data raises, it must show me that you know me Symphony created. And there it is. Okay, So if I do use you to make symphony okay, show tables and there is no tables from now about the database is there and it's created using Dr. And the next episode we see how to create tables and how to do a bit more advanced to talk with these doctrine 10. Configure Doctrine: So before going further with our video, there is a far lot was greeted behind the curtained and we did not talk about it proves video. So the previous really, really don't solve the or in package. And we have a new file which is doctor ableto Why Mel Duty ammo. But he's actually under the config Them pack ages then doctor in the PMO. So this fight contain it's tree off the ammo. So first of all, we have para meters and one of them is m on database. You're on as mentioned here it under the fullback database. Ural, if the envy of our is not sat So, for example, if I did not define or something happened wrong with while insulation off the bundle off the actually of the or M package, I could simply define that database. You're right here, and everything will be fine. But also, we have a definition off doctrine. We'd to a notes inside it. So the 1st 1 is D B A l. And if you remember, we talked about this in the previous video D A b l and or am so right here, I'm defining the claim. Not but Hey, the symphony flaks did define this. I would set the driver to PDO my school the server vision of 5.7 their charts at utf eight and before the full table options shot set on DCA late on the You are old. It's here pointing to the and the resolve, database and resolve mean forward Go fetch that variable from the e. M file Right then the second thing is or m and ease with actually what defining options for our object relations hamper. So here we have ordinate proxy Teoh cast the true my naming strategy, doctor, nor am naming strategy underscore auto mapping to true mapping. So this kind of still be advanced it for now. But will we see in this and the coming absurd? Here we have the type sanitation that it's type sanitation how to represent the database tables, whether into unit ation tables or yeah, we go, we will be getting back to this And here we have the day are where we will be defining the entities that will be representing tables in table SQL tables or mongo DB tables collection whatever into a simple PHP classes that will have properties and methods, etcetera. So we have also the prefects are like a name space. Use it inside these glasses and the alias is 11. Create First Entity: Welcome back to this new episode so far. We didn't create our table out database story, but it does not contain any table yet. Now it's time to do such things, and it's pretty simple yet we a symphony and doctrine, we won't be going to PHP mind me and agreed that classic old way creating a table defining all the fields. What is the name of what is the Barca? What is over waiting to increment, which is the member and all that hustled? We won't be getting into that, but yet again would be doing it through the command line. So yet I would like to jump into my counsel and I would like to type each be then slash council And he don't that simple as that on right here We have bluntly off all the possible options. We have doctrine we have way have lend. We have, um Oh, and what will interest me here is this Make and specifically make entity and as written here as the script and create or update abductor, An entity class on and optionally an FBI platformer source. Okay, for now, I will just stick out this level off disc documentation. So again, I will do Beach Bay been slash council and I will do make entity and hit Enter. Let's see what will happen. So it does ask me first class name off the entities to create or update. So I will say to dough, since we are talking about to do okay to do without an ass his enter the new property. First off, all I have to do an entity i d. So I would do I d Yeah. I would like to show you that doctor and hunted that also villas so you don't need to bother yourself. We have created a my day or incriminated or two in command and primary key And all that stuff is handled by doctrine, which is really amazing. So just focus on watching it. First of all, our unique to have it to do name so very logic that will be a var Caro string And it be 255 Can this be? No could say No. Andi Yeah. Others another property. I would like to set this to priority. So priority will be 12 or three seem to be in number. We could set it too high or low. So let's stick with a string with filled and cannot be filled. It cannot be empty for sure. And let's call this stages and it will be like active or the activated. So to be string, we could stick with this. You can? Yeah. Yep. On they go Thoughts enough. So now everything is ready. Now, if I go back to the I d and in the folder, call it entities right here. I have a new class created called to do dot PHP. Now, if I jump into it, I found that I have a class Oh, peach, because that is representing all the data I was typing. So we have an idea that is generated by doctrine on with this annotation defining some properties or or a me too mighty. It's generated value, which means, like, little increments on. We have the type here, which is an anti job. Okay. Also, we have a name which is a on or in column and defining that properties of So the type is a string length east to five. Same for priority. Same for status on the good things. Also, that we have getters on setters for all pretty much the names except for sure the idea that it must remain the same all along the life off these entities. So that is really amazing. But yet if we jump to the database, there is nothing. Call it to do table. So to do that, we need to persist. These data so are said here in this terminal, it's at next. When you ready create a migration. We've make dot Meg aeration. So right here. I simply could copy this on. Do bitch be Ben? Flash council Tired That and hit. Enter on. Look what's happened next. Reviewer migrations arrested, see migration and then around the migration Peach pay Ron Opie, HB been And this come so simply come p this on first. Before that, I'd like to jump and have a look at this file. So it's my great SRC migration version Assoc Migrations and we have this one on. It does contain and SQL syntax off all that things I was typing before right here. So I have an I d. I have, um priority. I have the name. So this migration is likely transforming this class into a readable, readable my sequel San Tax Okay, so they go. Okay. Now, the next thing is to execute this migration so simply by copying this and executed directly and let Okay, so application migration warning You are about exit to execute database migration that could result in a schema change. Undated loses. Are you sure you wish to continue and hit just since it's empty and there is no worry about that. Now, if I go back to connect to my sequel so my single that you should be road should be on connect and they'll be used First of all, use. Um, what is the name? State based out. Was you to me, Tudo. Hopefully I spell it correctly. You need me to do it? Could just grab the name from, um from here from the A M v. You okay? Lets you do me symphony. Okay, then I simply type show tables and it will show May that I have to migration versions and I have to do containing actually nothing, but it's there. So if I do select all from to do, it will show me nothing else. I just misspelled something right there. And there you go. So it's empty. There's nothing there, but we have an entity transformed into a table and it's ready and existing into our database 12. ORM & Entities: welcome back to this new episode of our course. So in the previous episode we had two actors that we did plied with. The 1st 1 was doctrine, and the 2nd 1 is Entity was Entities. And let's talk about this latest. So behind this title lies the truth. So simply an anti D with the or AM a key I object. Relational mop Irwin manipulate and record in the database is really nothing more than a simple pH. B object and doctrine is the Orem right here on the RM is simple. It does take care off, recording your data by making you forget that you have a database. Yep. How is that? It's by simply by taking care off everything, we will no longer write queries or create tables via ph me mind mint or any other client in our PHP code. We will use doctrine symphony default over rams and to do all of that. So Anu Aram, there is a batter letter in which is a no which is stand for object indeed, for everyone to understand all your data must be in the form off object. All that say entities. Since we do now that we talk entities mean objects. Using an object is not a big revolution in itself. Let's suppose we have an entity called User and it has also an email field lecture we have on our to Dio and two days. Okay, so to do user, get entity, get email story, for example, as we did here, for example, let's imagine we did instance she ate this on that We did like this or dollars to do. Get email that's supposed to have any more right there. Yeah, and itself. This is not It's pretty, but it's not like top new things and it's limited. Yeah, So let's suppose we have a user with this user. Let me just like this. Uses off course. Follow May. So let's suppose this users have a commanding system. Let's say we have a commanding system to our application, and I would like to have commands like written by this user or a silent to this user. So what? His revolution is to couple this object representation with a warm So what do you think off doing? User get commands on commands are stood inside another anti t a k a table. As we said before, So, Yep. You could not do that with your painting. Right? So here the method User get commands would trigger the right query and will return of exact commands, which is like a table or object table containing all the commands that are assigned to this user. This image do present pretty well what is doctrine, entities and the relation between them. So first, before we have on the left our object product object, for example, we have an i d. Name, price and description. And all these information are represented in the form off at B H B class as we did with to do. Let me just get me off this to avoid any right here. So we have all the feeds defined here. Okay. Back to our image and right in the middle. That is doctrine. And it has to these big arose and blue. Okay, I'll be back to it in the seconds and the right side. We have the databases, the physical database with all the SQL. For example, right here structure. We have 12 as an idea. The name, the price, the description, cetera. So back to the doctrine Here we explain the rules off a middleware converted would like to call it like this way. It does has to a race. One of them East gaming from the object to the database on the other one in the opposite way. The 1st 1 I could call it like coding or transforming this object this beach be object into a valid My sequel structure on the opposite is doing the exact opposite. So it would be taking data from the SQL version or type off content and transforming into an object that could be exploited late in tower coat. So right here we are, including our decoding all the other way. So, for example, if we'd like to define and 90 of 12 then I have to use the set I d or sat name or set emails that whatever liquid it here And if I'd like to get data from this side too this side, I'll be using the gathers method that I'm defining right here, and actually I'm more defining myself. But doctrine the RM itself is defining and auto generate these getters and settle. So this image just doesn't really represent what is or him on how to deal with entities 13. The Migration: alone will come back this new episode so that they would be talking about migrations in the previous ones off our episodes. We didn't treat it to do entities, and we did persisted through database. So the migration passes through iTunes steps and this step number one is taking this object to do object, for example, and converted into a version of a file like, say, name and version. We update prefects with second even Teoh on pH before And it has is hided two very important method. The Method number one is up, the 2nd 1 is down, and as the name and she said, we have something that would be creating and other one would be dropping. So if you do read, the SQL query is right here. We have a creative table to do, and the other one is drop. It's able to do so. These are two different methods that will be using through the migration process that create or drop tables from the database. And to be able to run migration on Symphony, we need to have a doctor and migration bundle installed into our applications. So yet again, we could have Teoh symphony recipes and downloaded from the using composer 14. Save records to database: welcome back of this new episode. So we did so everything we need about our entities and have to persist them on, actually, how to migrate them into the database. And today's video will be using these entities to actually insert data inside the content. So to do that, yet a really simple using symphony and all round this coupling is really amazing. So to do that, I start by defining an e m, which she stand for on the team manager. That would be equal to dollar this get doctoring and I'll do get manager. Okay, so what does this line me right here? We are injecting. We are using the e from the solid programming topics. We are injecting dependencies, which is the manager off doctrine on to have a brief information out like toe show you a beautiful website. It's actually the doctrine project Hot Dog that is talking in details about this on the team manager. So it does say that entity manager is a central access point off, though to the your, um, functionality. It's for Sade to all default or different. Or am subsystems such as unit off work, query, language and repository. AP I EST initiation is done through the static. It create method, the quickest way to obtain a full configuration or for full continued manager. When did the manager? So this is like a brief introduction and hopefully visas explain Natori so entity manager will lowers to access the AP I'll off doctrine that could manipulate our entities and persist data and fetch data from the database. No, let's go back toe idea and finish our to tour your course video. So the next thing is to create an entity. All right, so our entities there, but I will create an instant in Aniston's Oh, I will instance she ate it to have an object. Call it to do so. To do that, I'll do to do equal to new and to do and make sure to imported and imported from the name space right here. That symphony could loaded correctly, and the next thing is to use the Sutters method to define specific information for specific for ages specific field. So again I'll do to do and I'll be setting this status. So, for example, I said the status to ongoing back out of be setting this priority. For example, I said it too high and also a good set the name or set it to great you to me courses. And finally, I will set the date creation and right here pay attention because we will not accept anything. Well, let's say we need a specific type of content because we did define this to be a daytime in the face or we have to do like a new date, time like that. Pretty cool. We could put semi color right here, but we are not finished yet with our examples. So there is two more instruction to finish First of four do e um, and do persist. So this method, let me just jump into with it does day the following tell the object manager to make an instance men aged and persistent the object will be enter into the database as a result of the flush operations mean we need to exit use its flush in a way to inject. To insert this result off the flood off the persist excuse May to have inside the database . So note the persist operation always consider object that are not yet known to this object managers as a new does not pass the Tatchell object to the persist Operation Island? Probably thus Oh, this does not have any sense. But don't worry about it for now, OK? So process actually persist the object that we created but not like inserted into the database. So first of all, I will pass our to do object as a perimeter right here that we could be resisted. Then the next thing is the doing Dua e m possessed or flush story. So right here It's said that this object with object will be entered into the database as a result off the flush operation. This is what we are actually doing and that should be fine. Now, if I go back for a testing demo, where is my counsel or simply by accessing viewed me path right here. And I do refresh. Let me just back to the council that you could say that there is nothing yet inside our table. So do select all from to do. And yet there's nothing. Outset is empty. So back to the browser and simply refresh the page. Okay, we have our classic Jason response, but we don't know what happened to the device that is Go back and check it again. I'll be just refreshing the same query. And there you go. We have a record with a 91 or two generated, and we have the name created, and we have the height ongoing. Okay, I type a day in state of G, and we have the diet exactly as we define it. And yet everything is fine. And we did insert our first record using the entities and or, um 15. How to Revert migration ?: hello and welcome back of this new episode. So in the previous episode we played around with entities, we did update them. We did great, even record into the database. But let's suppose, as it happened with May, I was playing around with tables, and somehow I deleted the table How to res at my database into that current state there where I have that to do tables or any other table existing. It's yet approve off utility off migrations. So to do that, yet pretty simple. So I'll be running Pitch by Ben Console doctrine, migration. Execute and execute What does actually do? Let me just grab a documentation of From From Symphony website. It does said that migration or executive Torrey does execute a single migration version up or down manually. So what happened down may mean it's pretty simple. If you do remember where we do spoke about version ing, we do say that we have to Method one is up on the other. One is down on what's up down does generate. It does alter or create a table. Other one. It does truncate or drop a table, so yet it's very xlf. Explain Natori. Let's go back to the out terminal on right here. We have a flag dash dash up, which means will be executing the up method, which is this one. Okay, then the next thing the next premier is the version file which has this one right here or any off these ones. Okay, so now if I hit Santa, Look what happened. Warning. Let me make this bigger. You are about to execute the database migration that could result in schema. Change on data loses. Lost. So are you sure you would like to continue on die? Simply type? Yes. Now look what's happened. So the error we are seeing right here has no relation with the to do on detail. But actually with the migration table So as mentioned here, there is a problem with the duplicated primary key, which is the I d off this version. But if I check my tables, I will see that I already have the to do table. So inside this council, I do show tables and there you go. We have to do table, ready to be working with. So then just first of a lot, check that everything is fine in term off like the attribute of the stables. I'll do select or describe describe to new, and there you go. So we have the I. D. Priority status and I am the name and everything looked pretty if I accept this with with with the migration fire, which is not big trouble for us for now. Because simply inside the migration table if I just select old from and their score versions. And there you go. I have limit based that right here that you could compare it. So 26 is already there. This is why we are getting that problem. All right, so that was how to revert your changes using the migrations. 16. Update an Entity: alone will come back to this new episode. So in the previous one, we said that migration is a tool to create databases, stable cetera, but also to update our entities and directly update the database. So let's suppose I would like to update this to do entities by adding a fair. Let's suppose I'd like to added a date off creations. So there is two way to do that, first of all, the manual way. So I just came here on Define a public first of all, elect to keep things organized like the fine. And you, um, new a new variable new entity, Paar Meter Call it Date and the flying What is the definition off it and create its getters , etcetera, and does a Next we do update we'll run the doctrine doctrine migration story. Also, we have another auction again through the command line, which is pretty much simple than the money will stop. And to avoid any problem with the camel case and low case and that kind of stuff, we could simply Ron teach the Ben Council doctrine and instead of doctor and I would be running make entity. Okay, so here it will ask me to insert the entity nine I'll be saying to do Okay. He tanta I Look what happened here. So you ran. Did you already exist? So let's added some new field. And I believe this is pretty much simple and easy than typing all that code by yourself. So I see I will due date creation and this won't be a strength. It will be in date time. Tanta Okay, I did a mistake here because I type it incorrectly the daytime type So it does like suggest me some inputs so main type relational type and you could serve for daytime which is this one without a couple to see Hit, Enter canvas field Be new I said no added another appropriately. I want added anything and look what happened next. So if we go back to our entity, would you see that we have a date off creation? Added into our entity we have is specific definition which is daytime and also we have the getters and settles off this attribute. So we have gained date creation on does return in daytime interface on also we have the set date creation and does accept did creation off that off type daytime advice. The next thing let me just get back to the council. It does guide us to run Mike migration, so let's go ahead. But before that, I would like to jump into my sequel minus your route, and I would like to visualize the database. So do use use. Hopefully, I still remember it is you to make you to make symphony. And how do show tables on we have to one of them migration and other one is to do. And let's go ahead and display this structure. But first, before that, let me just select all from to do, and it will show me nothing because it's still empty. So it's empty. Very simple, this scribe and tie to do. And there you go. So it has I d. Name priority on bond status. Let me open a new council and I'll be running Beach Bay, been slash console and stayed off make. I'll be back to show you that it requests us to do make migration instead of make entities are do migration. He don't, uh, next to review, so it does generate a new version for us on their migration folder on Run the Migration Tool. So this migration make they'll generate a new file. Let's go ahead and see what's going on inside it. So we have this with 2019 date. Exactly, and it does have the new data inside it. And if you look carefully, we'll be finding the new altar table and other creation date. Okay, Critical. And again, we have a drop, its default out of table to do drop, the exact filled that we added instead, off dropping the entire off the table. All right, so actually, it's out there not to drop my apologies. Okay, let's go back to our terminal and I'll be running beach. Be ben, slash console men, slash console. And I do doctrine now because we'll be talking there later. Base so make doesn't have any mission to do, doctor. And take the hand Migration migrate tanta and everything is fine. Now, let me just go back to this window off my terminal, and I will be describing to do again. And yep, Would you see that nothing did happen because your number I am because I did not really date. I apologize again. I'm just make this slightly bigger? Yes, and it does said that Ultimate table does finish correctly. Now, if I do run this again, I do have the creation with the time newest falls and everything is pretty fine. 17. How to Revert migration ?: hello and welcome back of this new episode. So in the previous episode we played around with entities, we did update them. We did great, even record into the database. But let's suppose, as it happened with May, I was playing around with tables and somehow I deleted the table How to res at my database into that current state there where I have that to do tables or any other table existing to do that yet? Pretty simple. So I'll be running Pitch by Ben Console doctrine. Migration. Execute and execute What does actually do? Let me just grab a documentation from From Symphony website. It does said that migration or executive Torri that's execute a single migration version up or down manually. So what happened down may mean if you do remember where we do spoke about the version ing. We do say that we have to. Method one is up on other one is down on what's up down does. Generally it does alter or create a table. Other one. It does truncate or drop a table, so yet it's very xlf explanatory. Let's go back to the oil terminal on right here. We have a flag dash dash up, which means will be executing the up method, which is this one. Okay, then the next thing the next premier is the version file which has this one right here or any off these ones. Okay, so now if I hit Anta Look what happened. Warning. Let me make this bigger. You are about to execute the database migration that could result in schema. Change on Data Llosa's lost. So are you sure you would like to continue on by simply type? Yes. So the other we are seeing right here has no relation with the to do on itself. But actually with the migration table So as mentioned here, there is a problem with the duplicated primary key, which is the I d off this version. But if I check my tables, I will see that I already have to do table. So inside this council, I do show tables and there you go. We have to do table ready to be working with. So then just first of a lot Check that everything is fine in term, off like the attribute of the stable. So I will do select or describe describe to do and There you go. So we have the I d. Priority status and I under name and everything looked pretty if I accept this with with with the migration fire, which is not big trouble for us for now. Because simply inside the migration table, if I just select old from And there you go I have a limit based that right here that you could compare it. So 26 is already there. This is why we are getting that problem. All right, so that was how to revert your changes using the migrations. 18. Fetch single record from database: welcome back. So in the previous video, we did create an insert data and saw the database. Now let's gather data back from the base and this play to our users. So first of all, let me just start by creating a route for our method. So I start by doing route or a trout, and I will mention the route I'll be pointing to So it could be you too may slash details. Oh, you to me to do we could call it whatever you want. OK, The next thing is to set up the name and you also free to said what name you want. So I like to do under school details the details on Don't forget this double quote do you details are just personnel. Great. The next thing is great. A public method for public function. That's cool. It get details. All right, we'll get it to do. You could call it wherever you want. Really? And right here I'm First of all, I will instance she ate an instance from our to do entities. Let me just define first of all, a TD or to do equals two the entity manager. So get doctrine that we could get would have. We do inject actually structuring inside our method. And from there I'll be using the its repository on this repository does take a problem eater. Let me just click on it. So gets the object repository for a persistent object. And it does take the first part a meter which is a persistent object which is the name off the persistent object which is actually entity that would be using on the second part. Amir is the persistent manager name the object manager named Mill on by default is one OK Don't bother ourselves with the second perimeter For now, the more interesting is the 1st 1 on the 1st 1 will be pointing to the to do entity this one So I start by copying this basted right there so persistent object and make sure to important from its name space and would be loading its class And if scroll a bit up, you will be fine that you are alluding that entity right here. Okay, so the next thing is to execute the query and this is as I said, one of the best features off doctrine. So you will not be typing manually select all from where etcetera doctrine will do us directly will do us these things. It will facilitate things for us. So I will do too. Though I look what happened now I have these method ready for me. So we have find which is taken an I d to a specific record we have find all we have find by we have find one by on We have get class name. So in my case I could use one of the visa threes. All right, so if I do find by O find one I have to pass a 90. They find all it will return me all the records room and find by, for example, would like to search by name or by priority etcetera. So for now, since I will be returning on Onley one, I'll do fine by one. Or find one and passing the I D off one. Okay, that's enough. So right here. I could do Bardem dollars to do And look what happened. I will do Get name on this missing this myth. That story is actually taken from the to do. Let me close these ones. Then it's taken from GATT name is actually this one. Because here we are returning an object that is, for instance, this class. And if you do remember what we talked about, dr in on that coding and decoding. So now we are getting data on. We are cooed in it into an object version. So I'm able to do the following right here. So let me show that in the browser, make sure that I copy the path. Never gay too. So in the fine get name method must be start start with either find bio fiber one. Let me just back to this I have We could just simply do this to speed up things I find on type the idea right there. And next thing keys Thio added to do equal to that refresh the page we have created is a reading me. Don't worry about this ever because we are not returning anything will fix it value in second. But right here we have that name that we did insert inside the database. Okay, let make things more clear. So let's return response. So all we do return new responds and fresh And we have this to do create you to me. Course. Okay, that's it. How to return a single instance or single record from the database? No, Let's imagine. I passed, like must support past end as a 90. And I don't have this idea inside my table. So we need to catch that. So I would do the following. If not to do. Then I will be using the throw method, and I'll be saying the Lord of this Crete phoned. Oh, great. Not found exception. Okay? And I'll bay saying no record for the to do with the I d and we can get tonight. But I d, for example, could say it. 10. Right here. Okay. Don't forget this. Simic. Kahlan? Right here. No, if I do refresh my browser yet again. Look what happened now. Record for the to do with a 90. Okay. And in advance, in stage off, this course will be creating, like, a custom file for such errors. 19. Fetch multiple records from database: No. Let's try return more than one. I d. Okay, First of all, I have to hit back on this road, which is to do slash name, actually, this one. So I shooting me That will be inserting record inside the database. Okay, so let's call this cretin. New unity cores. Uh, publish you tube videos? Of course. All right, low. Let's dangerous changes too low and hear slash you to me. This will owe us to have another date Uncertain. Side of table. Okay, now let's return all that data. So you see the find I will be fined. Oh, without any I d. And look what happened now. I could not do this because this returning result is actually a table. So I need to do Ah, four loop. But before that, I would like to do print are or right here inside here I will do print are but to do. Okay. Now let's refresh the page. Make sure that you are on the right path for fresh on. There you go. We have a zero, and we have one. We have two recalled. And let me make this slightly more beautiful. I'd like to utter the pre for matter. So pre and right here, another pre slash three hoops. Great refresh on does not take any effect, but it's there. So print, we have this first record with the create you dummy course right here on. We have the 2nd 1 called Publish YouTube videos. And as I said, to loop through, we need only a four loop to look through. I'm just repeating myself. So I'll do four var before dollar X equals $20 X is lower than still lots to do darts. Okay, um, that length I cannot forget account. Yeah, I'm just coming from a new angular eight. I was off work and I will do Dola Rex Blast. Plus. Okay, so right here I could do don't large to do off eggs. Come on, Dollar X and actually brackets not curly braces. And I could do get name. And don't forget to this cynical. Now, if I do refresh okay, because I still dumping this somewhere right here. Okay. We don't even need thes ones anymore. Que every does them. No fight. There are I forget to hit Echo right here. That's why I won't have any results. And I go. Let's make it slightly more beautiful. Other than a p on right here, I'll be uttered another P Onda fresh and they go. So we have created you to be course publish. And this is the static message we are setting right here. Okay, that was how to find an item from the database we find in all the one item we find a lot of item. No, let's find an item by eats like a name, so and stay in the final. I will do find by and look what happened with this find by. So we have the criteria we have ordered by. We have limit and offset. And this is what is interesting for us. So I would like to show you how to find by. Okay, So let me search for find by I Look what happened? He it does, except list off tables with each tables containing the key word on the keyboard. Oh, and their value for sorry for that. So the 1st 1 is the name from the entity and the other one is the value. So let's apply this into our example. And to do that as yet. Pretty simple. So find by and I'll be passing First of all, a table. The 1st 1 is the name on The name is from this to do for sure. Right here. Okay. What is it? The name Great at the name I would like to set. It equals to this. Let's call that, for example, publish YouTube videos and it that now if I go back and refresh Look what happened. I have only one publish YouTube video records. Now, if I do change this, for example, this changes to night who just falsified it. Look what happened. No record for the I d. Off them. Ok, so that was the three major, like queries or methods that we generally abusing inside our tutorial to find data from the database. 20. The Query Builder: Hollande will come back. So as we saw in the previous video sometime the final find bio fund by ideas. Not really perfect in term off result. So hair it come another player, which is the repository. And this repository is actually a class that allow us to create our custom methods that could generate square ease to the table to the database. Actually on right here. Doctrine don't generate, like, a boilerplate, for example, that we could use to run these out to create these method. So right here I would like to pass them, just go back to the to do, Actually, to my control, I would like to execute something like this and simply create you to me or simply create or even you, Timmy Otto. Simple as that. And find all the record in relation with this. So right here it does not return anything right here. Actually, it's broken because I still not defined the repository. But if I do find by find all will find by Ola School this and name name and assigned you to me, it will fail to find that record inside the database. I've never record for the time because we are hard shooting this stand right here. Okay? So, as I said, we need another way. And this to do is another way on this every positive, actually another way so quickly I will be simply I will be creating new method and, um, starting from this one to speed up things. Okay, I will in commanded right here. And let me just a sign. A bit of commanding to it. So find the like to a specific to the input to the input value. Simple as that. Okay, so let me explain. Line by line on that will be going in detail in further videos. So first of all, I am instinct. She ating create Curreri bullet, which is a class by symphony. It's part off the or I'm right here. If you could look up in my i d That a creating you query builder. Instance on, as the name explained, we are building a query right here. Stick of this level. Keep that in mind, and we'll be seeing this later in very big details because it's a big dude. This credit Buller. Okay, so this very broadly we are instance she ating in new instance of it we are doing defining in a nail years to our table. Let's call this since you are about to do it's called T. So it's probably abuse so on and where this is the statement that we are going to define. So t is an alias to our table. Don't be pointing it to the name. And look what happened with Mike when I d does pick up that you are pointing to the name failed from the to do repository Oh, to do anti story And here we are passing the dot valve. So we in the next line we are past, we are injecting. What is the world? We are defining this well to be the value we did inject. But he I would like to other than a bit off update to this because I need to find all the Brickell but look like that What? So here, instead of equal, I will update this to like because I think it's equal. I must type the exact syntax with exact string together results. So change into, like will increase my changes changes to have a result. Okay, Now we order by TD with an I D Well done. Um, by the i d and ascendant set, Max results will only need to return 10 characters or 10 results. Get query and get result will execute the query. Okay. No. If I go back to my you Timmy controller and I have to update it, so instead of find by, I will do the following. So I do find by example filled and right here we could through for sure, like updated find by by email or by name, find by name, and that's more significant. So instead of find this, let me just to rename it to the new name. And don't forget to pass your keyword you to me. And if I do refresh Woop something went wrong because I missed a semi colon right here, which is normal now if I do refresh Look what happened. I have to create you to me course. And now if I just changes to YouTube, Look what's happened. I have published YouTube on videos published of YouTube videos. So that was how to create your own custom query. And as I said, we will be getting to this layer and more details when we start implementing our to do list 21. Update database record: hello and welcome back to this new episode of our course. Previously we did Fatchett data from the database right here there is a mother, like an option to have for our user, which is updating their content. So let me just back to my database and just view what's going on right there in term, off two DUIs. So right here I have to to does one is greet you Timmy courses. The other one is published YouTube videos, and each one has its own A priority and status. And let's suppose was that that's suppose I would like to change the priority off, create you Timmy courses from High Teoh Too low to normal, medium or something to do that. It's yet pretty simple. Just follow me along and you will discover that so back again to our controller Udine controller. For now, we only have one controller on later will be creating more them, and I'll be creating a new method and this method. I'll call it update to do okay, so let's go ahead and career first to fool the route. So I do what route again, and this method or dysfunction would take part a meter, which is dolar i d and it will be injected from here and saw the path. So this one will be an antidote, right? Okay, The next thing ease to get votes specific record from the database using using this I d To do that, I'll be speeding up things by just copying this lion. Actually, I'll be coping the entire function and I'll be updating it line by line to fit my needs. So first of all, I am just using the doctrine the get triples jury to fetch, not by name, but I'll be fetching by and criteria. And right here How be fasting and array will contain an idea as key on the value will be dollar idea. Perfect. Okay, the next thing is to set up this this ever handler. So instead of heart Cuda 10 I will be passing the I d. So you can cut teenager to the every message. The next thing is I would like to remove this because I won't have a table will return. May weather off falls when there is no record found or a true Owen object. When something is found using that passage idee so get rid of this for now. And let's just vote. Damn pull printer. The result for now. Simply. Is that okay? Okay. We couldn't concur tonight. This for now. No problem with that. Okay? Not a fat black to the browser. And I do hit slash am bait and I'll be passing one. Look what's happened here. Don't worry about this, but look what happened here. We have that record from the database, which is great. Now, if I do pass like 10 or 100 whatever now record for that specified I d if everything went well, If we do not follow on this error, this will be an instance off the to do repository right here. Which means I have access to all the getters and the cetera. Smith it. So let's suppose I would like to update the priority, as we said in the beginning of this video. So I will be set priority elected just copia to avoid any type o. Okay, so this that priority take a string as a para meter right here. Okay. So sad. This too. So it was, I believe, low or high before I would like to change it to allow for example Low. Okay, The next thing will be storing this new record. These changes to a database the only exception that would like to update this. A bit of code. I would like to keep a reference to my repository. Teoh This a class injected with this service, actually. So I would like to do the following. So right here I will keep reference as an anti T manager and I will be replacing this piece of code. Okay. And I will be get repository. Perfect. Okay, Just leave the rest as it is. And right here. Once I did update the fields, that's added a bit of commanding. Update the fields. Okay, I'll do flush that object. Okay, Hume, I said, Why not? We did not use possess than flush. It's really optional, right? Because it's simply already watching our object out to do object. So there is no need really to tell doctrine to persist this object, then just then flush it to the database. So what would be doing is simply too, of the entity manager story. Andi, just call the flush method on that product on that object, and that could be enough. OK, no. Let's go ahead and test this. Okay, First of all, let me check that. Everything's still fine with this. Now, if I pass a 90 off one, which is valid. So we have set priority on an array and the problem here that we are calling the find by and it does return an array. Okay, So instead of find why I will be doing find and I'll be passing idee and automatically what's happened here? I don't need to tell doctoring to find it. By which criteria it will know automatically that he will be fetching using an idee. And look when I click on this documentation. Okay? Come on. It does return an object or a nail. And if there's return on object, this object would be off type to do. Then I'll be able to shut the priority and execute that Sattar from the entity class. Now, if I do back and refresh my browser, everything went well. Don't care about this one. I would like to move back to my database. Refresh this. I'll look what happened here. I have this in you. Oh, priority. Okay, are just okay. You may get confused because we have to publish YouTube because I did execute that twice. Don't worry about that. Just focus on this line, Okay? It was high before, and now it's Lo and everything went well. Now let's supposed like to play around with this and just say this to medium again medium. Hopefully, I spell it correctly. Now if I do refresh Look what happened. If I do refresh my database yet again. Eats updated to medium So everything went well and our record is getting updated. The other thing. I would like to show you that I'm able to unlike what happened here. Um added to pick up. And now that this object is the entity, So I could also said the status said the priority are said the name, too. So said the name. Let's added, updated a liquid. Look what's happening. Look, what am I able to do? Set update and I could do to do troops actually, right here on the other, the calmer and to do yes name updated. Get name simple as that. Ok, now let's go back and refresh it again. Everything went well. Don't feel Don't care about that, ever. No, If I do refresh my database Look what's happening there. Okay, Okay. My apologize because I'm coming from a JavaScript background JavaScript day for exerts no more. But I forget these things now. We will be having update on update because I lost the previous name and they go so we have update an update and everything went well. I care. You can just play around as much as you want with this functionality and of the and you will be able to update your records from the database. Always side with the device. 22. Delete database record: finally now, crude without a delete, we have to have that functionality in our application. We need to able to delete these records. Let's suppose I have this example when things are duplicated. I would like to get rid off one of them to do that yet pretty simple. That famous word I'm just using all along this course again, I will be creating a new route for our method. And all because of this delete to do just keep Aled simple on because to do slash and I'll be passing the I d. Ok, then name are set it to the lead to do simple as that. The next thing is the method definition. So right here I will do public function and call it delete to do okay. And this method does take an I d that it would be an anti Gia And yet again I'll be co being this three old to line of code right here. So look what happened here. I'll be using the anti demand your reference. Then I'll be calling the fine method that will bury toning that will return. Actually a 90 Owen object will know. So I would like also to have this error handler. Sorry, This one, actually. So when everything went wrong, we must display that message elsewhere. I'll be doing to do do lots to do also re entities manager and remove. And I'll be passing this object, which is the to do. You guess it pretty simple, isn't it? And finally, we have to flush these things to the database. Flush. Okay, on, right here. We could set return. You response from http foundation article or to do with, uh, let's go with a string interpolation to do with an i d dollar I d is removed correctly yet ? Very simple. Okay, now let's go ahead and test these things in the browser. OK? Where's my browser? Okay, so this is the update held like to the late the number three. OK, this one and elite number three hit enter to do with three or the I D three is removed correctly. Back to check that everything is fine in cyber baby base to refresh. And there you go. So the idea three is gone and our databases updated. So that was how to dilate record from the later by using doctrine 23. Doctrine relationship Introduction: hello and welcome back to this new episode. I would like to agree to you for the achievement you Richard, so far, now that we know how to create and manipulated Single and today we comfortably can put another give Ron. We know how to store information based on our entities to the database, but we quickly found ourselves limited. Let's suppose we need to store a user i d in relation with created to do into our database . It's a big question to answer. Right hair it come the relations solution from our or AM doctrine. There are several type of relationship between entities to meet sever concrete needs. These relations are want to one want to many and many to many. So it's so could be taken a core concept and how this is implemented Before looking in detail at relationships on how to implement them, we need to understand how they work, so this is really important before proceeding ahead. So do not be afraid. There are just do things to put in mind before attacking anything. First of things is the owner and professed concept. The notion off owner and in verse or rivers is abstract but important to understand. In a relationship between two entities, there is always a so called the proper unitary entity on DSO. Call it in verse. To understand this notion, we have to go back to the old age when we were doing our database by hands. But also we have. The owning entity is the warm but contains a reference or i d off another entity called Rivers were in verse. The second thing is the concept off uni, directionality or bi directionality. This notion is also simple. To understand, a relationship can be one way or two way, meaning if we can re tries a using be on vice versa. This relation is called bi directional. If not, it's called uni directional relation between these do entities. 24. Explaining relations on board: So I would like to explain this honor sketch ball would that we could, like, see it on old waste I like in schools. Okay, So start by representing the uni directional relationship. So I start by other than the title right here. Call it uni directional. And I'll start by creating our to do. Since we this is the topics off the scores. And let's suppose I'll create another table 20 days. A key. I had a call it user. So as I sat in this in the previous minutes intro off this video, let's suppose we have to store this user information I d into this. Did do. OK, so to do that, I would like to start first boy, imagining that I will use that user I d somewhere inside that to do, right? Okay, So the revolution, the revolution. So the relation here is one directional. So this is to do is called the property the priority Terry entities hardest bell. Meaning that the oh no, it has the user. I d inside it. It has a reference to the user inside it. Right, But the user does not have a reference to the to do inside. It mean it's uni directional, This is water main uni directional. Right. Okay, Now let me just move this forward and changes to bi directional and what this bi directional need to update. So instead, off single reference decided to do, we could create another reference that will be stored inside this user. And it will be referenced Teoh to do and their school I d, for example, right. And in this way we could dro these two lines. So from the to do, I could get the user and the from the user. I could get the to do since booth are storing reference to each other's. No, I would like to talk about the type off relationships. We said that we have a three types which are many to 11 too many and many to many. Okay, so let's draw them in our example. And again, how will be drawing user or stop by to do and will be having user. And let's start drawing these relation between these two entities. So I start by 1 to 1, Want one mean that a user have a single to do and it to do have a single user, so it would be one one and meaning that you do cannot have multiple users and the user cannot have multiple two DUIs. Okay, so let me just type base right here. One, 21 It's south splainin story, but I'm just place it correctly right here. Okay? The next type is one too many in our example Want to many One user can have multiple to do so the logic side but one user can have Okay, let me just draw it correctly. One user can have multiple to do and this is 1 to 1 one too many. The other relation is many to many which is not applicable really a logically in our example. But to explain things, we admit that its logic, which is to do, could have multiple user and user could have multiple to do so to drill without we could start by doing this era that will be in both direction actually, So we could have infinity off users right here. So let me just drove infinity right here and we have another infinity and other born and let me added many to many, many to on again The name is self explain the sort. So many too many. Okay, since we did explain things like that, let's go ahead and see how to implement them in codes and how to update exactly our entities to fit our needs of the planning on a level logic. 25. Update entities with relations: Now, let's see how the two week our entities defeat a specific type of relation. And let's start by doing the many toe one relationship. So, first of all, I would like to create a new entity called Users, So had to our route. And from there I will do ph b been Let me make this bigger in console and called the make bundle and do entity. Okay, So close Name will be user and let me other than a name for it. User name, for example. And that's it. Okay, we could stop at this point. Uh, no, I won't uttered any other property. Great. And right here we will do the mapping between the user and the to do so yet again, I will execute the same code. But we to do basically been consul make entities. And right here, instead of typing a new name entity I will do to do Okay so he detect that already exists. There will be adding or doing an update. And right here I'll be typing user and hit Enter. The next thing is the key. The field types are instead of string or number of something else. I will do relation and look what happened next. If I hit enter What? Clothes should be this entity be related to. Okay, so he detect that we I would like to connect to at mother Entity And he asking me which glass to connect to a k which entity to connect to. So I'll tell him I would like to connect to user. Okay, so look what happened here. What type off relation is this? He's asking May What type is it? Many to many? Is it want to many? Is it many too many or East Oneto one. Okay, so in my case, I will sigh I would like to be would like it to be many want to one. So meaning that want to do Could be refereed or beer forensic to a single user. So I will type 1 to 1. I'm just copy this and hit their 1 to 1 hit. Enter. So is this to do Doc use a property all over to be new? I would say no. So I could not be creating it to do without assigning it to user it. Next. Do you want to add a new property to user? So that you can access update to do object from it. Example. User get to do yes or no. Okay. And this example, I would say yes. And right here hey, will create the failed reference to that to do inside the user. I will let him pick it automatically. So it to be started to to dio hit Antar. Others know the property. No. And there you go. So, no, I would like to jump back to my i d and discover what did happen right there. So let me just closed a lot. These files and inside the entity stable, I will have a new league created entities called User, and it has a bunch off code that is really interested. So first of all, I have the private stuff and order generated kind of things. Is your name the redefine it item or field? And right here we have what is interesting for us. So, first of all, we have the private to do and annotation or am slash Want one? This is the finishing off the type and we have the target entity. It's the name space off our to do anti dates and it's Muppet by user Cascade persists. Remove cascade Main Oh, persist, escape. Persist mean when I do remove, for example, the I d number one do remove the user number one. OK, so this is not really logic in a real life example, but it does explain the relation Want toe one? How does it work now? If you move back to to do entity, let's see what does update happened there So if I scroll a bit down, I will find a user defined And somewhere this is the newly created failed This is called ah user and we have the definition off Want one again. So have targeted anti the name space of the user and we have inverse it by okay to do and we have the cascade versus to remove and we have the new created file user on we have the updated to do. Okay, so let's just dive a bit inside the code and discover what's in you. So inside the to do everything looks the same, except with the newly created attribute, which is user private W's on this one, and it has a specific annotation starting by at Warren. I'm just reduced this so at or AM and 1 to 1. And we have this target entity properties. It's pointing to the name space off the users off a control space. It will take me to this entity right here, user, Let's go back. We have inverse it. But what is this? Inverse it by its a property from the priority Terry entities, pointing to the inverse identity and specifying which field is reference to this to do entity inside the user. So if I go back to the user, I'll fund that I have another property. Call it to do, which is this one that is actually referencing that to do inside the user, right? Moving back to the to do yet again, we have a cascade equal possessed and remove meaning when something happened when an update or delete happened to the to do, it will be reflected directly whether removing update er whatever, especially when the to do get removed than this year's or get removed. This is not allergic and real life, but this is the purpose of explaining how want one does work, and right here we have or enjoying, Colin said it knowable to false meaning. This user cannot be new inside the to do know, moving back to the user. Would you see that we have exact same annotation with a bit of tweaking, So instead often verse it by. We have Muppet by and Muppet by mean that first of all, this user is the inverse ID entity, not the priority of the property. Oratory are still struggling with promising this world eso map it by. It's actually pointing to the user. And this year's there is the reference off this entity inside the to do which is this one. Okay, then Cascade possessed. It's exactly the same as we talked about inside. The to do are this point. We could proceed with the migration since we did created the entities and everything should be ready. So I'll be placing myself under the route for my application on executing the migration creation process. So ph b. Being council make migration. This will generate again a fire from a under the migration of SSE Migration folder, and it will be running this run that will generate the migration for me. So just copy and paste it. Give it a second on application migration. It don't set. You have four Meg Oration Previous The databases there are not registered on migration. Weaker escape that for now. I sure Yes. Okay. Warning. Just it. Yes, on. There you go. Actually, we're getting this error because we did set rule to not accept an empty user. I d inside the to do table. This is why we get a constraint violation. And we have this cannot added over today the child root for the user i d But now if I go to my database and check the structure, I do see that I have the user i d already created and everything is fine. And also, I have the users table created. We have the I d and the user name. And since we are on a development stage, we could do some hard, right resenting off files and database. So I just start by defining at colon type options for the full value that could be set it to zero. And the Tudo same thing default could be zero to And the next thing I would like Teoh check onto my database to be sure wolf tables are there. We only see that we have only migrations version this mean that we cannot execute any migration because the table yet does not exist. And it's just generating liken other version off tables, and we cannot really lay on that. So what should I do now? Actually, I'll be executing a specific migration file. So I had Toso see migrations and I'll pick the very 1st 1 for example, this one and executing it on a migration. Okay, so I'll be back to my terminal and clean all the smiles and I do migration and just to see which want to execute. So I'll just picking this command. I'll do migration, Kahlan, eggs, acute dash dash up and passed the I. D hopes off that file that I just lost. So I have to just pick it again. This and there you go, really date. And we did run into this issue which is again related to the migration table. As you may noticed here. So another hark for this is to truncate this stable so I'll just select all of the wrinkled and I will do truncate. So no, if I do Ron my migration another time, I normally should not fall into a vote issue and let me do it again? Yes, on we have the same issue because the to do actually does exist and that to do already exist. Sir, everything is fine. So we have no problem with this. Did okay on the to do is there But we still don't have the user. So we need Teoh. Generate another migrations. So I would like to first of all get rid off all the migration that can cause trouble. Just get rid of all of them, right? These ones and back to my terminal and I'll be running make migration again. Okay, then how executing BHP been console migration, My great. And he gente yes on we have another issue right here. So it does seven treat a table to do and it does fail based able already exist Another hard way to fix these things. And since we are again in development stage because just with everything and rebuild it from scratch S O B being console doctrine Big database drop dead slash force And there you go. So we did lose everything. Onside the database I'll just one or make migration on all the time. We have to pull actually the database so sort of that we have to do great here. Okay? It's created. Create the migration fire. We need to just the jumping to that file and make sure that everything written inside it is correct. So we have created table user on. We have a great a table to do on. We could run that migration. Now we closed I that everything will be fine. Okay, All want. Well, great. Now, if I go back to my database and check it, I you must see I have the to do table and with the user point into where and we have the user we to do pointing back to the property that proves just still struggling with our priority. Torrey. I am today. Now it's time to do a bit off one to many relationship. So I start by creating a category entity that is placed under the entities folders, which is this one. It does have a single property, which is the name, and that's it on. I'll be creating a product category. Property would be a relation. So just taking a relation and the doctrine will fetch the rest. And he does ask me what entity should be related to. So I'll tell him I would like to link myself to CART, agree on defined the relation type. So right here from the product I'll be having many categories and from the categories I will have one product. So I'll be setting their relation to money many to one Just copy that based it brought here . And you could imagine the logic so many products could be assigned to a single category and single category could be a sign it to multiple product hit Enter Is the project relation property alot to be new? We could sell it to yes to avoid any problem later And do you want to added new property category So everything s so you can access update product object from it Example category get products So let's go ahead and type Yes and you feel name That's enough at the new property, okay, And everything is fine now. Now if you move back to my i d outlook to discover the newly created the classes So I'm just closed All this that things get clear on die have category and I have a product. So we, as we saw in the previous video we have relation to find it for us. So have many to one. And we have the inverse it bar. And since we have invested by this means that this is the priority Ori entity. And this is like the inverse it by because it does not hold the i d off the sign it productive with right. So we have I get products, all of them. We have added the product to it, but it does not know which products i d is. Okay, so, no, let's go ahead and update our database. So I'll start by doing a migration, make migration grated, then just run migration it. Yes, and everything went well. And the good thing Now, if we move back to the database will discover that we have some pretty cool stuff created for us. So first of all, we have this category right here that is containing idee and name and doesn't know anything about tables. I think I did not finish everything. Okay, so we have finished. We have one migration executed for school queries. Everything is fine. No, if I move Teoh products, I do father to have the idea by default, the the relation i d And we have the name. So this is the relation i d as we define it to be pointing to, uh, the categories. And now finally, let's discover the many to many relationship okay again into the terminal. And I'll start by creating a first entity. And I will call it City and you get the point. So cities and users or villages or what is the word? A citizen? Yes. So the first thing is the name on the next thing is what? So the type of it okay said everything, Teoh Okay, I can't be spilled can be No, no. And I wont added any other property and right here creating new citizens C d citizen citizen hopefully spell it correctly and the name off again. Okay, You won't be new to 55 can not. And now I was said the relation so added. Okay, sorry. I just don't spell something right here. It must bay again. So I just like things citizen citizen I think it's any instead of e But anyway so the name so suddenly to and I am feel name that everything. No. And right here I will say city okay. And it would be a relation to city, and it will be many to many. Okay. Do you want other? The property, I say yes. A new field name. It will be, um let's call it, um, citizens that it is. Add another No, generate everything. And let's go back and check our i d for newly created stuff. So seems like it did not pick up, so I have just to refresh it. Okay. There you go. So I have citizen right here. We have citizen. Okay, just this is the 1st 1 I aboard it, actually, so you could get rid of it. We have also city right here. And there you go. So I would like to move to citizens within ass on you might see that doctrine or that they added the ask for plural stuff. Okay, we have moppet by and we have this citizen that's containing an inverse advi right here. And it does return a new right off collection or write a collection. And I really do invite you to move to doctrine website to really to learn about this collection array. So, doctrine, I'm just drag this right here, so doctrine Ray collection. And this article actually does explain everything can details. And what is this, uh, ray off collection? Right. So NRF collection is a collection implementation that rob Riggle Beach be array. Uh, okay, simple as that. So let's suppose, um we were with us. Return, like, collection off cities. Ah, dependent on the user and this array of collection lowest to execute an extra operation. Like adding, modifying, deleting or the kind of stuff I really do invite you, Teoh, flow this link. Okay, great. Now let's go ahead and update our database. So right here I will do make migration. And after that I will run the page pay famous MK doctor Migration. Yes. Okay, great. So we have create citizens. The citizen. One does get created. But anyway, in a problem, we have Citizen city and this is the magic that did happen here. So since we talk about many, too many mean the to booth entities have reference to each other's. So no fair move back to this, and it just scroll down to my database, which is just refresh it for a second. I do have that I have Citizen City table created so It does contain citizen I. D. And a city I d So booth off the two entity will have reference toe themselves to each other , actually. Okay, So, citizen, we know what is the what is the city and the city will know. What is this? It's, um I d So that was the three type off relation. Um, doctor And specifically and I really do invite you to practice this small that you could. I understand the fundamental and the main idea off relation on difference between them into , like, simple example as we did right here. And start inserting. And this is what we'll be doing. We'll see how to insert content depending on their relation type. 26. 40 relations in actions: So today's video will be putting all what we know about relation in actions. So have start by creating a 1 to 1 relationship on, and I speed up things by creating all this coat. So let me just get you through what's happening here. We are getting the entity manager. We are creating new instance off the user. We are having also another instance off the to do. We are setting the user name using the set name with it that does accept a string. And Max, we deal with the to do so are setting the various properties. And right here we are setting this set user, and we are passing the user object right here, since it does except, um, object off type user, as mentioned right here. And it's optional with that, um, without a question mark. Okay, The next thing he simply persists that to do and automatically, we don't need really to pass this because addiction will handle the rest for us. He would you know that he must persist the user before the to do you know what to do? Actually, and finally we do the flush. And now if I do just move back, Teoh a test and let's just refresh, Okay? I did not set out any message to be output ID right there. But if I moved back to my to do table, I do see that I have a name and high depending the dates descriptions. And I have the user i d 23. And now if they moved back to user, I will father toe have a 23. We're 80 user and the name Allah. We said it correctly and right here will be exploring the many to one how to store many toe one relation and save them to the database. So the example in our application is the categories and the products so category can have multiple products. So you start by creating a new category right here. I just said it a name I did persisted that I could ensure that it will be saving to the database. And later I started a loop from 0 to 4 hour three, actually, that I will generate for product for me and said dynamic name for them and right here set a relation. And actually, I misspelled when we did when we didn't create the relation instead of Quetta. Great. I said it you relation, But anyway, so set relation me and said they could agree. And the next thing on final thing he's dish to flush everything today the base and return all went well. So now if we just refresh it does say that all went well. Now let's go ahead and check inside the database. If everything is really went well, so changing to this Mr Refreshing check the categories. We have symphony courses, right, which is defined right here. Right. And he moved to products. Normally we have four products. We have product 01 These dynamic names and relation I D or category I. D is pointing to this idea and finally, for many to many relationship so yet again, I see that things by creating this block off goat and would happen here. I'm getting instance from the city and the citizen, and I am setting the name for the city and associating eight. You, too, and associating a citizen to it. You're using the added citizen and doing the same thing. Um, opposite way with citizen. I'm just defining the name than other. The city right here and passing this city as problem eater and finally just persistent stuff and flushing. Now, if you move back to the database, everything should be fine. So first of all, this is the Inter Mediate table between the terms Citizen City. We have citizen I day associated with this citizen with a city I d 22 And if I move back this city, I do have my city created correctly. And if I move back to the citizen, I will find that I have another one limb. Just just really a different data that we could say alway, let's spurs Mohammed Andi, Let's go for tunics. Okay, Let me just refresh the page. Great. Now, if I moved back to this and refresh, I have three Tunis and I have a newly created citizen where actually, this is the Inter Mediate evil. So you have 33 now families back to citizen. I have my newly created user or citizen inserted correctly to the database 27. Form in Symfony 4: welcome back to this new episode of our course. So in the previous video, we're playing around with the crude operations on our to do records. But the user is still really able to manipulate and do action on himself. Since we are almost on the cases, we are hard coding the ideas and the content that we are inserting into the database and on this section of our course will be a lowing the user to input his own data using forms. So the topic off this section will be forms. And let's go ahead and have fun and discover what these forms can do on the symphony applications. 28. Install form component: Welcome back to this new episode by default. The symphony 4.2 don't have the component off forms ready, so we need to install it at once told. It's yet pretty simple using flax. So had to you wrote on Open it and toe meet route by the roots of your application and open it into a terminal and just around. Composer require symphony form Tate Anta Let flax do the rest, so in my case, it's really install, so I won't let it waste a bit off minutes of your time. And right now we'll be ready to start creating our full so yet again composer require symphony form, and you could go and the next things would be creating a very first formed that is based on our to do entity. 29. Create a First Form: welcome back to this new video. So today would be building the very first form in our life. Okay, Seems fun. State. Okay, so what we will be doing right now he's thankfully or thanks to the symphony maker bundle, which is the fastest way to generate the most common code you will need in a symphony up like commands, controller form classes, event subscriber and yet more. Okay, so let's go ahead and see how we could use this maker to create a full yet pretty simple. So I would do PHP then space or slash, consult and make Don't for simple as that and hit Santa. Let's follow along. What? You what he's going to tell us. So right here is telling us what? The name off the class you would like to create the name of the form. Another term for the cause of the food. So, for example, let me just pick this random name Victoria's elephant type and hit answer. The next step is really important right here. So let's suppose you would like to create a form that it has no relation with any entity I don't know. Like can the name for the form for Ah, just any random input or in my subscription, the important that it will not have any relation with any entity whatsoever. You will not type the name off the entity right here. You simply hit, enter and yet ago. Okay, let's go back to our I d and see what did happen right there. So the very first thing we do see that we have a new folder created. Call it form and inside it that there is this victims you elephant type class created. So right here we have pretty neat and simple of a theatrical asset that's based on Symphony . So first of all, we have the name type the name space story. It's up slash forms on. We have a three. That's a library looted from the symphony. Bundles are Symphony Vandross story, and we have this class with that extend the abstract type so the abstract type will be used for the different types of input. That suppose we have input, name, input, text input, email, input, password, phone number, etcetera. So it's coming from this abstract type. The builder interfaces used right here to get access to this can admitted that it will low a low as to added fields into our forms. And yet, finally, this resolver is used generally for for the validation purpose, etcetera. Right here. Okay, so this builder does have plenty father method. Okay, You do see. But we have added which is which will be the main method for us. So in the steak, first of all, ah, name. So we could use this like a news letter. Okay. I always misspell things. Okay. And right here we'll be passing in a write off options defining like the placeholder or the max number, the lunch. It's that kind of stuff and yet ago. So this is the very first type off forms. 30. Create Form based on an Entity: So the next sigh perform is the ones that are related to a specific entity or specific class. Okay, But to the terminal and just back to the history hit Santa. And look what happened here, right here. I could just type whatever the class name is. So to keep things, um, what is adequate? I'll do to do as the name of the class. Simple as that. Don't have to put the tea on camera, guys. And right here this is the way he will ask me for which lets say, entity, You would like to well, this form from if I'm saying correctly so it would be to do Andi. That's also everything is telling with success right here. And it'll generate off to do type inside the form folder. Let's go ahead and discover it. What's going on there? And you will be amazed by the power of this maker, Toe. So right here we have all the import to resell before within a port off the to do entity, which is amazing and right here with the form builder method. We have a builder with the other name. Priority and status on these weird are defined it inside our entity. So yet again. This is how to create a foam based on a symphony entity on a doctor in entity. And the next episode we will be seeing how to display these form inside our HTML twig files . 31. Dispaly form in twig template: Hello and welcome back. So as promising in the previous episode today will be inserting this form into in each HTML fire and have something displayed to the end user. Okay, so everything is ready. We have the class full, which is this one and all where we need Easter. Just implemented inside on a controller and just surrender it to the front user. All right, let's go ahead and see how to do that. So, first of all, I would like to declare a form variable. Simple as that. Okay, so this will equal dollar of this and look what I would be calling right here. I will do Crete full. Okay. I would like to jump into the documentation off this method. I look, what does it take? So first of all doesn't take a string or type of types drink, and it has a data to and there is plenty of options. Okay, so the description says that create and return off form instance from the type off the form . Okay, So, first of all this mean the type and the type mean, for example, our to do entities, our to do forms right here. Then the data mean the data that could be inserted inside the fields off that form. So let's suppose we are editing a data. Oh, a data from a to do right here. So we will be having to do containing a data. And this data must be displayed by default inside the forms, as we do in Facebook or Twitter, Whatever. When you do edit your for example email when you click on edit on the form, you will find your existence or current email and surgeon by default right there. So this object data is used for that purpose. Okay, enough talking. Let's go ahead, implement these things. So quit form right here. As I said, it will be taking a to do type. Okay, so I'll do to do okay without actually dollar. But to do type and let my idea a load the rests out be loading the class and I won't be passing any data revisions. I'm just inserting in state of anything. So right here, let me just get rid of this one, too. And I have up form to do type loaded up off my class. Okay, So the next thing is to bind this glass into our view. So other to the name also I form for example and I'll be injecting that form and not that form exactly. But I'll be calling a method from it which is creative. You so this creative you. I'm just again jumping to the source code. It does return. It does return like the HTML presentation off this four. Take it simple as that. OK, Now that the foam has been created, the next step is to render it. This is done by passing that special of you object to our template. So other sad note is the Crete view. So let's go ahead inside this each day my file and do that so I will do form on this form does except a problem eater which will be a formed view on all safe for now. Let's go ahead and test that everything is fine. So right here I have nothing. No, I do refresh. Look what happened. I have the name within input, the priority and the status on all all these inputs already to start working with the next episode will be playing with these Feels like changing the label, changing the type, etcetera and see you in the next one 32. Styling Form: welcome back to this new video. So we need to create the form in the previous episode. Body Atlas Admit that it's really ugly and for end user vases on Nightmare. And this is like a former from a my aunties. Let's go ahead and see how we could improve it and tell me if you I make it slightly beautiful. So yet again, symphony does, uh, take care of this for us. So it does alot us to implement the boots drop forms into our application. To do that. There is two ways the waste number one is through a jahmal file. So if you do remember inside, okay, and just scroll a bit up inside the conflict pack age there is like setting for specific versions or specific modules. So we have ones for routing. We have doctrine, migration of doctrine, the cash, etcetera. And right here we have trigati. Amal's right here. So right here we are defining the setting for that wags stuff. Okay, By default, there is a default path for the twig templates, which is Colonel Project and templates. And which is this folder? Okay, this folder we have the debug on the back and some canned off definitions. And 40 meters on, we could added the forms Theme. Okay, Right here would like to other this and I will be added ing the boots. Drop four layout dot html The trick on you might ask yourself whether hack did that that this came from. Okay, It's pretty simple yet again. I will be leading you into the Vander folder, the jungle off Symphony and symphony. Right here on under the twig bridge. There is re Seuss's folder containing views, and inside these years, there is a form on inside this form, there is a three or four dumb blades related to the form. So if you notice here, I'm taping boots, dropped four layout and simply this is it. So boots wrapped for layout html the twig. And you could, like, copy this lame. Okay, I cannot update it. I'd like to just copy the name, but you could pick any template you wish to your full. Now if I go back to the form and I do refresh the page, please pay tensions that let me make this bigger. The reason no class inserted for this input. Now, if I do refresh look what happened. I have a class called form Control the famous bootstrapped class. But yet again, you may say, Oh, it's still ugly. It's simple because I don't have Brits, Robin, my application right here. So let's go ahead and deluded. I'll go to get bootstrap. I Hopefully I could get it from Syrian tow. Avoid downloading this kind of things, letting check for the city in Vega. So I'll be coo peeing this line back to my i d. And if you'd like to play it right here since we still don't have any like big templates, I'll be creating ah skeleton off my HTML page right here. Andi, I'll be moving this stuff inside the body back to website Refresh. And there you go. So this is much more beautiful than it was before. And this is how to integrate bootstrap and make your food more beautiful and more user pleasing. 33. Twig extending feature: Okay, that was beautiful. But I think you nude is that we fall into a bigger problem, which is, like, I have to do this every time. I would like to create, like, a new file. New page. We have the beautiful style. So right here it came when we call twig inheritance and layout. So this in simple it's mean that will be creating a file that would be call it the base on all the template will be extending from it. So this foil must be placed it under the template folder. Let me just close this wonder because we did fly round enough with it, and right here that it's already there. So this is our base template. Okay. And this file, as I said, it will be like the sewers. That other template, though, extended from Okay, so let me just update this file with the boots drop looted in the previous video. Okay, To be clear, I would like to don't lose this file to speed up things. OK, but for now, I will simply grab this link and place it on the Bay's file. Okay, so let me put it right here, OK? Oh, probably below the title is better. Okay, so let me just speak a bit about this syntax. Okay, so first off, the consequence html tags head and the body etcetera. And right here we have a block title with work on Something on and Block. So we are defining like a placeholder for other inheritor. If it's correct to say that the other inheritor template that will be extending this to inject content from them directly in these places. So, for example, in our four, we generate this block off content. When we do inherit when this to do does inheritor from the base, it will be actually injecting content right here inside this body block. Okay, this can be confusing, but go ahead and put it in action that you will be in the wrist and of these things in details. Okay, So instead, off all this hunk of junk stuff, I will just remove all of it, and I will do extend. Okay, I have to extent on, I'll be saying please extend from the bays dot html. The trick on on clicking on it. I'll be redirected to the just to make sure that I do extend the correct file and breath. He I could start using blocks so we do block and look what happened here. It will know that I have on Lee for available blocks. OK? And also sure I could create like more blocks. Let's told this, for example, block stuff for you to be stuff you could call it whatever you want for sure stuff. Okay? And don't forget to close this block and the block and right here I would have mawr stuff. Oh, you to me stuff ready to be working with So right here will be using the body. Just paste that content and Onda block. OK, No, let's refresh back. Refresh this page and look what happened. I am extending that based on plight, but it's really messy because I did not set up the bootstrap stuff. But look what happened now. If I do hello anywhere right there outside any block, look what happened. It does broke because it's saying with this message, message is self explanatory. It simply that extend another one cannot include contact outside a twig blob. It's Freddy. Simple and easy to understand. We must always type content inside a block that is coming from the parent, which is based dot issue Mulder Twig. So we could remove this on. We could just improve a bit. This content in state of just throwing it without any styling. Olga do container on decided cases container will do. Roe and Cole off. Let's go 12. For now. Okay, Now, if I do a fresh look what happened here, Okay, this is much more beautiful and a bit more organized. So that was how to extend template. I mean, symphony. 34. Create a Form manually using FormBuilder: Okay. So in the previous video about the form we talk in the BASTAR practice, how to create a class outside the controller than injected fighting as we did. And yet so good. Practice is good practice, but yet again, there is another way to create forms directly inside the class. One side you control. So to do that, I'll just move it down and I start by doing dollar full. This will run into an issue and temporary issue, because form is the final right here. I'm just demented. And how be doing dollar this. Okay, Come on. Great. Full builder. Okay, so this form bender is actually, if you'd remember, it was use it inside. The to do type of right here. Form builder. Right here. Okay, So this form builder does a low me to have access to several methods. Right here. We have this added, which is the most important one. Okay, so this added with alone may 1st of all to the fine the name off the field. Let me just the fun of this ours user name, for example. Okay, the second is the type as we talk it. If you remember in the previous video. So we say this is the type. So to define a type, there is Prue. Define a types and symphony forms. Okay, So, simply by control type andare start typing text and look what happened. So we have text area type and I have also text type, Simple as that. So to have a bit more details on this list off Vala types, I'll leave you a link. Ah, for a symphony website listing aeltus types. So we have Let me just grab this into the screen, so make this bigger. And I have text typed text. Oops. Sex area email type, money number password. There is, like 1000 of them. So, Olive, you think Teoh that you discover these things by yourself and see how much type and symphony we could employment. Okay, back to our form builder, Andi where I waas. So it was right here and I said that this would be a tax type and then I'll do class, please load the class. I also added another full filled. That will be a password type and again, I'll be leaving the cause. Okay, let's suppose that was enough for May. The next thing is to render generate this file exported to be able to be, like, implemented into any template. So this method, what will be calling is get full simple as that. So right here I will change nothing since I already have that form looted. Actually, the form inject inside the form and I'll have the creative. You ready? So now if I do refresh my page open. Look what happened. Cannot load a d bill text now not implemented on to face. Okay, it seems like it's looted from the wrong package. Sorry for that. So yet again. Pay attention from where you are loading your stuff. It must bay from the form extension core type and yet again refresh. And there you go. So you have user name and they have the password off type password and this is typed text. Know if we'd like to play, but more. I could set this off type email type and look what happened. Just make sure also that way, did imported from the correct repo or from the correct components, So yeah, and now if I do refresh, it will be off type female Doctor, inspect these things to be more sure that everything is fine. So I have form user name and the type is Yeah. So type is an M a great. So that was how to create a form directly inside the control. And as I said, this is not really good practice, sir. It's better to stick with the classroom that alot you Teoh like b'more oriented object coding. 35. Customize form rendering: Welcome back to this new episode. Today's video will be wielding a customized form rendering for now, everything is okay. But let's suppose I would like to display the priority below the status. Okay. You may say, Oh, yeah. You can just simply do it through the entity to do class to do type. Okay. You could revert these things. Okay? Yup. That's possible on. Look what happened. It does work, but we would, like, read. You have, like, a free control on our form. So to do that, it's yet pretty simple yet again. I'm just using, like, 100 times this word inside this course. Okay, let's go ahead to the template file. Okay, Let me just cause cruel to, uh, kind of method well using. And I'll be doing this inside to do so Instead of just calling this widget directly, I will do the follow me. So I just put this into a command for now and right here I will sigh to Twig. Please start off Froome start. Okay, so former start mean I will start injecting form stuff. Okay? Simple as that. And to stop thinks we need to end it. So right here I will cite you will be using the form value variable that is full. Okay. And right here I'll just duplicate this. And as I said, we need to close this to start. I'll do Sai se Former Andi and Steak of four. Okay, now, let's go ahead and see. How does it look like when I do refresh everything? It's pretty normal. There's nothing different but right here, we could go bit further. So I will do. Since we are using boots drop, it could go on row, not cold six duplicated into three parts. And right here. So I'll do for MRO and I'll be inserting specific form input. In my case, I'll do form dot dot It must be name, for example. Let's go. Priority. Priority. Okay, now, if I do refresh. Look what happened. I have prayed. What? You're right here. The name and the status are beautiful. Like injected. Okay, So the next thing I could do is let me just copy this to speed up the process. Andi, Right here. How? Just based. That's a priority. Let's Southern name right here. And the next thing is this status. Okay, great. No, let's refresh and see how things look like. Yeah, So you have full control into my full 36. Custom Form Label: Let's suppose now I would like to update the label. So instead, off this prayer retail like to say it. Please insert a priority right here. Let's suppose that way. Okay, To do that, we'll be using the form label. So, actually, in Symphony On Twig, precisely. We have the form label, the form widget, the forum help. And the four ever. And I'll leave links to these things in details that you could discover is an more depth yourself. So right here to insert a label, I would be using the four label. Okay. Right here. I'll came to this point and the safe for my Look what happened here. Label. Okay. This full label, it will take for dot Priority. Now, I if I do display that it does show me the priority. But now, if you could apply around with it, I'll be passing some perimeters. Which will be the 1st 1 will be the name, which will be the tax that will be displayed. So right here, let's say out like to sigh, please set the priority you're ET hopefully I spell it correctly. Now if I do refresh Look what happened. Please said the priority So to solve this duplication problem, we would like Teoh so you could do it through two ways. The ways number one directly inside your HTML by just simply extending the form row, for example, for the priority all set label label, like so labeled Saturday to false. Okay, now fedora fresh, it's gone. That's option number one. The option Number two. It's inside the builder Method class to do type and right here inside. This added, for example, priority. So the 1st 1 is the type, so let's suppose like to define it to a text DYP. Make sure that is important from the form ah, from the form components. And the next thing is the array that would be playing the rule off para meters that I'll be saying please said the labels to non waterfalls or to whatever you want. Like hello from car controller, Like what happened now? Hello from the controller has simply by setting to false will to empty, we'll get rid off that okay, have to set it to false elsewhere. It's will remain there. Okay, that was the two ways to remove to customize your label 37. Handle form submission: Welcome back to this new video. So the form is ready, and the missing part is submitting the data from the user input. I'll go ahead another the submit button. For now, we could only use the Inter Teoh. Yeah, to display it as it is. Okay, so first of all, let me out of this bottom that could things go pretty well with what we are doing. Then just remove these imports that we don't need anymore. And how will move to to do type. Okay. And right there, right here. Actually, I will do Are that submit and of type type submit type. Okay, so it's not actually from this option, resolver, but instead, it must be liberated from the form. No, not there, but actually from the symphony form Extension Valley Day type. Yes. Yep. This one, actually, all is OK. And let me just remove this for now. Let's go ahead and test it. So if I do refresh, I have my submit Bottom right there. And validation the like. The bulletin brother Validation is active anti connection. So right here. I would like to set the priority to let's say hi without a t the name new user data from the foam. You could type where everyone for sure. Status? Let's say two. Panting Okay, For now, it's only like him. Um, random data for and later will be like fixing what the priority could be. The status and the only up from that users free to type is this night. But for now, let's go ahead and hit. Submit. For now, there is nothing really happening. So let's go ahead into the controller and employment allergic. So this method will be doing the rule off interceptor for a request. So the very first thing is to inject the request into this method. So right here I will do doula request. Don't forget the hour, and I will be passing. It's Robert. It'll be request. So it's came ing from the component. Http foundation request, which is this one? Okay, make sure that eats imported correctly. She's this one. Great. Now could go back to our form and right here I will do like if there is something submitted their then do X y zed task is so starting by a very simple thing. So I do if and if what exactly. So let's say evil. Our post. Okay. The classic beach bay. Ah, method. I will dio echo form submitted. Okay? And it would be saying later how to transform this into a symphony. Some tax. So now if I do refresh, I do re sound okay. I have formed submitted. Okay. And also I could do parent are dolar post okay Or to be more like authentic, let's say to request Okay, now if I do refresh Look what happening? It will show me the data that I inserted and started four set concert I said the priority to hide the name to new user data from the form and the status to pending. But yet this is not a proper symphony way to handle this kind of things because later would be implementing validations on. We need to be like fitting well with symphony instructions. So the best way is to start by the already created form. So let me just drug this above everything And right here I will do dollar form and look like methods I have inside this grass and I'll pick one of them which is handle request. So as the name is self explanatory, it will handle the request. I'm telling Oh, symphony, Go ahead and please handle request for this fall and lemon jump into this method. It does take a request as a perimeter. So the description says inspected the given request on coal the summit who are battling submit if the four boards submitted. So this method like will be the Ruppel for our firm submission when there is really a submission. So let's go ahead and other. The perimeter which is will be a request and everything is fine now. Okay, Now we go toe if statement So instead of dollar post will be typing dollar foam and there is not a method which is is submitted. OK, but for enough it will test that our form is submitted. Let's go ahead and test it. And look what happened. Everything. Still working correctly with the new content. All right. There is also another statement One other condition we could other into this statement which is on the validating. The full is unlike what happened. We have a bunch of them. We have a sink rises, route required is empty. It is able etcetera. There is also ive valid and this valid actually let me jump into it again. It returned. Whether the form and all the Children are valid when the form is everything is fine and everything is is okay with it. Then we could proceed inside this visions direction. Okay, so let me just refresh that everything is fine. Great. 38. Store submission to database: all right. The next step east to store this information inside the database. We did this before when we did insert. So I'll be screw ruling on actually searching for that part when we did create a record. And this is it. So just copy this block off code inside our method and OK, I have to find it. Okay, let me just do this. L k they go right here. I will do the following. So first off, before that, I would like to parental dumb the form data. How together? For example, when we did previously a native PHP, we do posed. And we said the name, for example, etcetera. How to do that in symphony syntax? To do that, it's yet pretty simple again. So I'll do right here to do equal or to do TMP. You can. You call it whatever you want to do. TMP equals to do our formula again, and i'll be using Get data. Okay, let's jump into this and see what does it return. So it returned the model date in the format needed for the underlying object. Okay, great. Now, which means it will return an object off the submitted data. Let's go ahead and print our dump. Yeah, some people might just using the dumping, which is much better since it's it's like bulletin. Ah, function in symphony. But I don't have it for now. So I go with a classic for dump. I mean, I don't have the bundle. All the components isn't installed in symphony. Okay, so when they do for dump to do to do TMP poofs, let's see what will happen there. It's okay. And we have an object off type on. Look, the type is that to do the entity object, which means I could do get name, and I do refresh what's Ah, yes, or it's a method. Now, if you don't refresh they ago. I have a new user data. Exactly what? I type it right here. Okay, so this is also one of best feature on the this Or am it like, return and object directly fitted to your entity. So, no, I'm free to do whatever I want. Okay, let's go ahead and bulled our object. So, first of all, I will have an instance off the entity manager off the doctrine and doctrine the manager and right here will start creating a new to do right here. So, actually, I want cretin you to do because I already have one stored right here. So the next part is simply persists this to duty PMO TMP and flush it that simple. Okay, no, let's go ahead and test if everything won't find Okay, So I did not set up any, Like, messing with something, but I would like to jump into the database and check if everything went OK. So I would like to open a new terminal for the database. How to do that? Okay. So select all from to do. He did enter. It's loading for a second. And there you go. So I have, ah, a new record with a 96 new data from the form high and priority expanding. So that was how to intercept user submission and how to insert them into the database. 39. Form validation: so everything is working very okay with our form. But it's no perfect because you may say, Oh, man, views you could type wherever they want. They could even pass any PHP script or any militia script into the four input. That's why we will be doing their form validation today. Okay, so the form validation there is two ways of elevation. Actually, their 1st 1 was or is by default the user of the browser input itself. So when he do hate submit on a required input, it will a lot of this kind of message. And if, for example, it's imagine this is an email when a top whatever, something that's not any male than you tell me, please feel a correcting me. Okay, that was like the first step of validation, the second stop in the back and if we could call it that way is through our code. So to do validation, symphony do present us who do extend also mawr, since its use in doctrines or doctrine does present a way to define how entity fields are validated, who should be accepted as validated. So let's head to to do entity and right there, which is there This one would be defining rules. Teoh to tell Symphony and to tell doctrine what the volley date and what not to validate. So let's take, for example, the name worries it. So the name right here I'm only defining the type off it, so I will do added a condition to be valid. So to do that, it's yet pretty simple using the art and I'll be using the assert. Okay, and right here I'll be typing the exact, like statement or condition. I would like toa have that my foam could be valid. So in terms of condition, we have really bluntly. And I would like to show you Web site from symphonies like listing of entire ity off possible testing validation as hype. So, for the basic constraint we have, the not newly LeBlanc is new, not new lease. False true type. It's a trial. We have string validation for email re. GEC's length is Bus World. We have also the equal constraints. We have all the scandal range possibilities will have a date. We have the choice constraint language, local church. While we have the files we have plenty of them on. You could like so them or sold them. You could check them through. Ah, Whistling Symphony vault com slash dark current and validation dot html. Okay, the next step before really implemented anything, we must make sure that we have the validator component installed into our application. So yet again, it's pretty simple through the command line. Make this bigger and I'll do composer while I'm under the Benz, I will do ph pay console. Oh, assorted would be using composer. So see day two, the route and your composer require there is any require symphony slash validator and this will do install the validator component into our application. Okay, so let's give it a second Taylor's finish that will be back. Okay, very well and very go. We have the symphony validator for point to 0.0.8 lewd and in stool it and activated. And thanks to Mr Flex, we could go back to application and start implementing our very first validator so back here and insert I already done that. So for the priority I started Teoh, let's say I asserted that it could not be in no okay. And hopefully I did pick up all the possible like inputs that I could insert. So let's do Okay, let me first check that everything is fine. Okay? If I do refresh. Look what happened here. There is no error, but let me put something wrong. Let's suppose I would like to have it milk. So if I do refresh. Okay, men, this is really amazing. I have this message telling me, Okay, it's a twice because, um, we did like of right the label. If you remember in the previous video, we did great. A custom label, and he does show me this value should be new weight. It's a ridiculous, but it to prove that this validator is working correctly. But let's suppose I would like to say this ours an email. Okay. Back to this. Refresh it, and I go. This value is not a valid in May 40. Form validation: custom error message: Let's suppose you would like to define our custom message inside off. This value is not valid x type today that it's yet for its simple. So it's back to entity and right here I'll just hope in these two brackets are defined a property colored message and I will set here whatever I want. Ah, this is Oh, this is not a valid e mail, for example, and you could pass the value into a bind. It actually to this message using the value property. Now, if I do refresh Look what happened. This is value or this is not a valid email and we have the value people right there. 41. Bootstrap template for the form: yet so good with our four. But we still don't really like this Twice error displayed on each input. So to fix this, it's really simple. So first of all, we have to understand from what does it came from the fact that we are using a template colored I'm just open to it. Osama were using the bootstrap, um, layout. Twig. Let me try to open it. That you could understand. What's the issue? S o. I will serve for error. All right. So the problem that each input off this template has, like, block for error purpose. So this is it. Okay, So the solution is No, Don't think about it. Don't edit this file, but just to use another template. So let me open whether this file is located. We will be using this always own tal layout. So back to twigged or Thiemo. And right here I would like to other under school or resentful. Simple as that. Now, if I do refresh Look what happened. It's gone, but it's highlighted with red. But there's no message. Okay? I also lost the label. Don't worry about it, but I would like to have back that message that error message. So to do that, let me close this mass and right here or anywhere inside my page where I would like to display the error messages I would like to added. Right here will do form errors. And I will specify what input error should be displayed right here. So I say form dot Priority. Please display priority errors right there of that specify section. Okay, Lego We have that message on Lee one on because I could play around with it. Place it wherever I won't. For example, if you create I like block for error handling on the top, so it will be separated from the input. Antoine's like break my template. So that was how to play around with validation. 42. Default data into the Form: welcome to this new episode. So today's will be is keep going with forms and that we will be editing data content using this for So the very first question to do would ask is how to like past data by default to this form that suppose you will be editing the form or the to do number one. I need to have the name, the priority, the name and the states right here. Like pre defined from the existing content. Okay, First, I'd like to fix this a label because it's really ugly. So right here I have formed label without any definition, and it could said Ah ah, ah, your e t. All right. Okay, this is better. And we need to load first that first record. So let's suppose you will be editing the number one to do. Okay. To keep things more organized, I would like to create a new method. So I was simply duplicate. Um I will duplicate which one update to elected up. Look at the one with forms on it. Okay, So just drug all this and paste it right here. And instead of to do, I'll do to do it. It to do. Let's added a dash, and it will be pressing an idea right here. And let me just update this. It it it it to dio. Okay, and it'll only it will actually take to perimeters. So the 1st 1 is the idea and the request for the submission purpose. All right, pretty good. So the for the first thing is not to create the form, but actually to load the data. So to love the data, it yet pretty simple since a sweded in ah displaying the form content. So I I'll be just dragging this line of code and let me just explain what's going on right there. So first of all, I'm Ludin. The doctrine and the repository on dime were using the to do class anti t a k a. And instead of fine by name, since it will return it right, I will only use the find by or find simple as that. And I'll be passing the i d. So right here I'll do dollar I d. Which is this one? Great. So this one is actually a number, but it's OK. You could keep it for that. All right, so the next thing is to pass this data to the full. And the question here is how to do that. So right here where we do the fine our form them just move a better off space. I was the dolar foam, and as we did get data, we will do set data. So, as you might see, hear it said that it except a model data. Another term it except an object. So sad data past that to do for mother code. Back to test on. There you go. So we have Okay, It's a bit messy, but it's okay. Ah, we have the priority medium the progress on the update. Now, if I do change this to to I would be having another data. Who? Hopefully I have a three. There is no three. So that's how to load data from the database and injected directly to the form inputs 43. Let's start practicing: hello and walking back to this new episode, I would like to greet you first on the achievement you reaches so far. I believe you learned a lot of things about symphony. How doctrine work, what is entities, what is form, how to generate them, how to update migrations, have to do all that kind of stuff. And now I think you are ready to attack another part off our Syrian, which is putting a what we know on actions on I do present you and welcome you into this demo application that we will be building. So we'll be listing our to do's like so and when I do refresh, I have on the 1st 1 open it and other one collapse said on. So we seeing how to integrate this prolapse panel collapse component from the symphony from the actually from the bootstrap and how to implement these methods The editor of the clothes and the delayed on Let's example that have a demo for this one, and let's added, like tpp or anything, and it will agreed, as were this beautiful message telling us that everything is fine and if I move back, I have that updated And when I do close look what happened. It does tell me that to do with an i d 10 is updated and it does turn this bottle circle to green. And also I have another one before that This close become disabled You cannot executed animal. And I have also visibly that alot me to relate directly to do. And it does greet me with his message. Okay. You like what you see. Tighten your belt and let's go see how we can do it. 44. Create the UI skeleton: Hey, how's it going would come to this new episode. Today's video will be bulling. This thing's OK. So starting for ease to do some cleaning. So first of all, I would like to clean this control or since its contain a lot of methods and some written then stuff. And yeah, I would like to change this and backs too, Like, just keep it on the export right here. Just removed up to it. The path to the road directly and right here will be loading. I will lay stuff to deuce. Okay, so let me see what's going on here. We have the doctor, An anti team manager. We have the new to do we have the publish. Okay, I'm just greeting in, seed off loading. So this is what I'm going to do. I'll just remove all this. I won't produced anything and I'll do two Duce! It cools to this. Get a doctor in. Actually who I am. Sorry. Get repository under be finding the app repository or to do repository who wanted the state , Actually, So that will return. And also using the fight old so that will return us a table that I could pass it to Ah Teoh our view. So right here I'm using adjacent seat of that. I'll do the render method and it does. Except two DUIs. So to do this will be the Delors two DUIs. Okay? And we don't need to have any path controller whatsoever. Okay? Ah, the next thing is too great. Um, the u Y the template. So right here I will do create an end accident. Html the twig. So starting by index dot html, the two egg. And yet but it it and I'll stop by ekes by extending the base the bays html took great and I will do block, block Let's go for the body and they'll forget their close it and let's type whatever I want. So hello from least seems fair enough ago to the browser on Just hit the slash I must have wouldn't get past Orender because I did not assign the template. So it's normal. So right here I'll be passing the Temple ICT which will day the index dot html which is this one. And if I do refresh hello from the list. Okay. Great. No, we'll be implementing this year. I so first of all inside the twig, the index basil bays. Dump light would like to create a container filled with that. It will be 100% with and coolest the header. Okay, Okay. Well, to agree. Thinks more organized. I will have the header right here. Where? The class. We cannot really assign a class. It will be divided into three sections. The 1st 1 is the the logo. Then search, then the bottom. So I will do container and decided he'll be divided into co four. Michael applied by three. And don't forget to other responsive ity. Call L G four and right here we said it to call 12. Great. So right here would be typing our logo. So logo be pointing to the root directory ordered to the root paths. Or so let me just define. First of all, let's do and the path it will be generated by smarty. So I will do path and it's simply assigned this. So this is the utility off the name off the route that we define it in the previous episodes. It's very simple by passing this Teoh right here, and that's enough that we could have that pointing to the resting. Okay, you may say Oh, man, probably this is not working. I Okay, no problem. Just added whatever you want. Hello. And look what happened. It does work. Look at the bottom of my screen. So you do see that I have. Hello. If I click Look what happened does take me to Valerie. So it's working correctly. No, let's subvert this back. The next thing is the search, so I will do form. Okay, well lets a stick with a simple input for now. So the import other The placeholder search. Okay, that's enough for now. Oops, I misspelled something. I am because I have to back to this road on and ah just have to other the row right here for a nice That's formatted correctly. Then the next thing is that plus bottom which is added new to do so creating a draft with a path to But to back to the controller. Let me clean this. Ah, where my clean this too. So I did too dio we have to define a route for it. So first of all, must have a form somewhere injected. So this is it. We could update this to added. There's neat. That is no need to have the name actually. Okay, I did. Where did use this name? Okay, we don't need it. Could just remove it on. We remove this one and we should be good to go. So added to do this is fair enough. So right here are just based at it to do. And I say plus okay for now we stick with a simple plus on. Later, we could update it to have something much better. Okay, so we have the four. But the hair is not resisting eso no problem, because actually, this template does not extend from the other one. But okay, we fix this later, okay? It's actually that sorry for that pocket. Personal style. And yet OK, now it's time to style these things. 45. Load assets using "Asset" : now I would like to create my own says as fire. To do that. It's really simple. So under the public eye created the folder. Call it CSS, and inside varies a style door sensors does contain, like a dummy style. She's a certain background color for the body and how to import this file actually to import it. It's pretty simple. So actually, there is two way whether using the link and the classic way so linkage draft etcetera or using the good practice of Symphony and avoid all the troubles like getting out on Blake Verbose and, yeah, avoiding problems when, for example, would you rename the folder, etcetera will be using a component called Assets Component. So first of all, we would like to install it, and I already done that to gain some second on this video. So it's composer require symphony assets and everything should before and after a second. No, we could go back to autumn plate and inside it there is a method that would be available so double calibrations, and it's called a sets so simple as that and a sets actually pulling to this public folder . So I'll do say, a sound slash style dot sas is on. That's quite enough. So if I do refresh its applied correctly and we have Assad's loaded using this component. 46. Setup Encore: So this illusion is really working and do the mission correctly. But I would like to tell you that there was another, more big advances solution, which is the use off the symphony. Uncle component. So what this component do and what is his mission? So his mission is simply to install the weapon Encore bundle. And where we do say what part mean that will be compiling something, bundle it and return it as a result. So if you'd like to use this weapon, Uncle Symphony, or simply starting by installing it so yet again, throw the recipes off Symphony. I will do composer require anchor, so it will take a second until it done. And I don't know if I should stop the video. Just keep talking. Okay? There you go. So it's saw. Ah, Composer, composer point Jason. So it does create composer upon Jason loaded the purpose It stories and stooling symphony were packed, bundled alone against on writing to the lock. And there you go. So the next thing is to install dependencies. Okay. What? These dependencies? It said that there is a packaged or Jason created, so I assume I say all the red stuff is and you re created. So I have What? That conflict containing a lot of configuration for this weapon. Ah, I have this set output. So, as you may say, here we have the output path is public slash build. So if I jumped to public, it's not yet created. But once I want this component, it will be created. Ah, so very set. Public part is build. So there is plenty off components set up. We have this added entry up a sets Jason up a sets dot slash slash up which is actually this folder created with CSS NGS Great. Ah, yes, I will. It is Bronte off definitions on set up that you could go extend it further with the official documentation. Okay, a bit down there is this package dot Jason that's contained some deaf dependencies. As so I don't really matter. And brother yourself, you're not family of javascript and know that kind of stuff. The only command that will be running that is in relation with node is an PM install. Simple as that. So npm install. What does it do with us? Actually compile and fetch inside this. Ah, this Let's say dependency. Sorry, I was showing this script. It does look right here and search for what? Dependency to install. And it doesn't stole them. Simple as that. It's like the composer. But in the full javascript word. So right here I will do MPM he for install and let it do its best. So everything is done right here. There is 8071 per Cajun sold, so you can imagine how the this node module is. Okay, so we have all the dependency needed that were packed. Could do his things on his way. 47. Encore in action: so that he could do if his things We need to tell him to do some things which is watching changes on these two files. OK, so I would like to open this and show you one thing, which is a require method function required does require simple as that when we do would like to when we do need, like, load any assets that let's suppose created in you, um style dot Say assess global or whatever you want. We have to imported right here that, uh, what back would watch it. So I will docs slash style dot CSS simple as that. So this is the purpose off required saying Forsa query if we need it. But we need to install it using using yard or MPM So yard is like, ah, other relative Teoh mpm it could you you could do your Alito could simply do an PM installed a query. Okay, Uh, okay. So the next thing as I said Easter are a command and the terminal. So let me drug my terminal right here. Okay. As you see, I said 1000 but it's 840 for that. So I do on PM Ron watch. Okay? From where in the heck I did came with this command. So it's really simple. It's written in the inside the package. So Jason and we have a bunch of scripts. I'm just run this watch. So yeah, So mpm when you told him mpm Iran and it will fetch inside the script, and it will find the water on bailed. Whatever. Okay, so for the environment will be doing and cold f dash, dash watch. Okay, so another term it would be compiling what is inside this assets folder to the output path . It's defined it right here. The set output bath, which is the public slash build on right there will we will be finding a bulled pack age, which is this one containing the stuff that we are needed. The next thing is to load this boult assets. So to do that, I'll be back to, um to my let's say, based on html and instead of, um, this one, I would like to update it to build. I'll be pointing actually longer to this. Fine to this folder, actually, sort. So to be build up dot sas is Andi. Let may drag Broza right here don't do what is the girl local host to avoid any cash problem. And there you go. So it's this purple on DWard does it came from It's simply written right here inside the assets. CSS up the CSS and it's purple. Let's go, um, Rose Orange. If I refresh, There you go. So right here would combine the assets component, and we also complain it it with anchor component. So you are free to use whatever you want and let's go ahead and continue with our work. 48. Enable Sass using Webpack: now I would like to use the South compile a pre processor, actually. So to do that, it's yet pretty simple and stayed off. Abbott says as Al just rename it to up both assesses. Okay, don't do this kind off toe surf reference because because it generally run into trouble. So we do that manually that you could exploit and explore the updated. So inside the abductor Js I will change this to abduct assess us Okay on and also inside. Ah, the weapon conflict. We need to enable an option. Force us as written here. Ah, enables house ss a support. Okay, now if I do run back Teoh the terminal, I will run into an issue That's I would like to show you so right here it run into trouble because it did not have this sauce loader component. I mean component that we are talking about mpm component on adult does tell us to run this script So it does npm install sous loader and it doesn't store it inside the dependencies off packaged all Jesus. So just simply copy paste that command hit Enter Let it do the rest. Don't bother yourself. Okay, let's wait for a second does on very go. Everything is ready. We could run on PM run watch again and it should be working correctly. There you go. So wielding went successful? No. If I move back to my application, let's may change this. Abdel Test us to Let's go for any custom anchor, for example. Like background. Not repeat. But let's go purple. Let me refresh on. It's working correctly now we could go ahead and continue our application. 49. Working on the UI - EP I: So the very first thing is to define the structure right here we have this header with this orange color. Okay, so I'll came here. I'm just get rid of this. See a will do header. The background is that orange. So I need to inspect it in the browser. Fortunately, I don't have foot shop, so I have to drug but image into a browser and use the pet from their color selector. So I need to have Google Chrome somewhere. Open it. Let me just open it right there on simply drug of the image. Comfortable shift. Why? And this is true K do for most off my work. Okay, so that was the first color for the header back to the terminal. Hold back to let me just move this back Some screens on right here inside my i d I'll pass that color now If I do refresh, I have that color ready. So the next thing is the color off the text. So the text here is whites. I do color color is white and watch layers go for a color is white Nice on. And for the over effect, the whole over outside color Let's go to G B I, for example, who could type whatever you want. Just keep it a bit off. Gray. Let's pick this one color on if I over. Okay, but without that underlying. So text decoration decoration to non. Okay. Nice. Great. I mean it. Okay, if I do them of zoom Great. No, I would like to utter the bit of putting into these, um these, like, blocks or the header generally so I could use it the implemented directly right here or using which dropped glasses simply using that do class bedding with a beat under old ash four, for example. Refresh over. That's a lot. So just simple to could be a fair enough. And they go great. So the next thing east ordered a bit off spacing below that header. Okay, as you may see here. So to do that, I will be using a bootstrap class, which is margarine bottom 345 So MB bottom armed ago for four. If they do refresh, I have that more space. Let me just remove this zooming. I was zooming my screen on. I would love to big this great Kahlo. That could be our player too, um, to the browser. 02 of the bodies story. So I'll be back to my screen to pick the color. And right here I would like to pick this color, which is f a triple. So back to the I d on our SAS file to the body. I'll apply that by ground color. So BG and simply passed that. Okay, Now, if I do refresh Okay, this is probably cash problem, but it's not because the color is already there. The next thing he's dropped like a white color for this center. Blawg. So I have to go back to the base html container Row on this is Ah, this is actually the header. So right here this is the main block. So you see the full 12 I goal ago collate enough. And I will other the class like Maine or simply a rapper. So back to this house under the header, I will sigh this rapper and the ground color will be white fedora fresh. You could see the difference. So it's right there. If you do inspect it really could see that then should change the color to something else that you could see it. But we have a problem that we have this, um Mrs Space. So the solution of adding padding bottom was like a bad idea. So to fix this I would like to remove this modern bottle from the header and instead I will added it right here. So margin top stayed. I'll do four. Actually, it will be parting instead of modern that we guarantee the continue city of that white background directly to the header. And there you go. I would like to change the color to something else that you could say the difference off colors because counter my screen don't show properly the colors. So if I did just change it to anything Comore dimmer, you could see that he's attach it to the top. Okay, we keep going. So the next thing is this little title and actually would be stopped working on the Beith. Ah, so electric change it to line in state. Stop working on the base and I moved working into the specific html to egg file. So for now, the work will be on the index dot html the twig, which is located under the template you'd may and acts and right here, I'll be inserting. It's an insert. A lot of concerns. Lauren. 500 words that we could see how it will look like. So they go. It's pretty beautiful. We have this on. Yeah. So the next thing eased to set the title. So to do that, I will be extending another block. So you do block, Okay. Just misspelled block. And I will do title and I'll say it on block shore. And I say to do Okay. Great. And look what happened here. It's updated to do up. Great. Now let's go ahead and fetch all the data. So we need to go back to the controller and right here I will dio No, right there. Sorry, but actually this method. So I'm already loading Aled the to do's and oppressing them other to do so if I do, um, close this close. This and this with one. But this one too. And right here we need to run a four loop. But before that, I would like to dump this to the said to do that double curly braces, dump method. That's it and passed it to do. And there you go. Great. So we have a non object containing? Actually, it's in Ray off object we have How much object? Let me just check. Normally they must be three. Three object. Okay, now we will see how to for loop all these objects to do a full open twig. This is the sun tax Defillo. So single Corey prices percentage four. Then let's say this to do in and we passed the to do's okay just to fix this problem with nomination, I would like to obey this 22 Duce and seed of to Do. And there you go. So don't forget also to close the four great and right here I have to do element. Really? That it could display sellers do Dupee on double curly braces. So in twig, when we do cooler braces, percentage mean that we are going to execute something A for loop a pipe, etcetera But when we want to display something, it's double calibrated. Ok, so right here I will do to do dot and they go. So as you see here, it doesn't map to the entity. So I do get name so it will be name, right? So normally what happened here is that, um I d, um, life such. Or find the name of the getter off the miss it just to tell me that when you do name we are really executing that Get name from the to do. Simple as that. Now, if I do refresh Look what happened. I have all the list off the to do's I didn't certain side the database on. We just keep going with our video. A guess I would like to creat this Thats kind of circle. So my idea right here is to create a span. Andi, I will tell it class equal to done. Ah. So the classes done or a status? Let's call it state is better. Stay choose. And right here I will do with if statement from, ah, from twig. Okay, so you get the chains now to explore how to do it quick, so I'll do f. And to do dot to do dot statement or status story equal two double equal to Let's suppose it's stated standing or it's done. Let's suppose it's done. Okay. We'll be inserting a class don. All right. Simple as that. Andi, if on this is how to implement the if statement in, um, in Ah, Twig. Okay, the next thing is to display this statement. Let's say ah to do dot status. Okay, hopefully this will work. Ah. Yep. Eso in progress in progress in progress. We have responding. What about ah adding a parenting class eso when it's banding How like to set it to don just to customize thinks Okay. Ah, And now it would be moving back, Teoh to the html who abducts us and right here. Is that the rapper I will do span that has a class status. And when it has, um when it has a dawn right here, please customize it. So, first of all, I would like to type the code for this. So it'll be the display in line. Block in line block actual has a border one pixel solid. Let's go for red. It's kind of random. Just hear Misspelled these things. And don't, Dan. Yeah, it must be a written like that on Let's go. Border radios to 15%. Ah, scale, background, transparent background color escaped for that. Simple as that for now. Now, if I do refresh, it's pretty ugly because it does contain attacks, but no problem we could added the heightened with height like 20 pixel. With 20 pixel on, we will be having like, a pretty much better circle. Ah, all right. I know a block to remove this don from here because we don't know not from there, but actually this. Yeah, so this will look a bit better. What about a vertical line? The vertical at Lyon Middle. Okay, this is better. So now the statement that will be defining when it's done, we need to set like a ah green color or something. Ah, and I believe this is quite big to read. This place are changing that to 15 pixels butter, 15 picks off right here. And right here on this red, it's not a good idea. So we'll stick with a C C C color. Yes, on. And when it's on, I will do background Teoh A scale for green Green on And I believe this green. Okay for forest Agree? Okay, now if I do a fresh look What happened? I have some of them were the green, but the border is not start. Okay, still, dash it. So I would like to go with no border rattle Okay, I will simply override the border right here. So the border will be also for his degree for us to green. All right, over To refresh This is absolutely much better. And there you go. So this indicate that I have these three to do is with the status off done. OK. Ah, right. We need to display also more than just the title. So for this example, where a description that we did not set. So I believe so. That time is now to update our schema and update the forms and like concert more relative on more explicated data. So we need to add it. The date and we need at it. Also the description. All right. Ah, great. So I will be back to the SRC entities to do's on inside here. Oh, well, we could do it manually or simply through the terminal. So let me just drag my terminal right hear clicking this mass And right here I'll be typing Ph b Ben Council, make mtt and D and hit Enter. It will ask me what my name off and detailed like to create our side to do and he would detect that is really existing. You will be in operation off later and state of creation. So the first update will be the created created date hit. Enter. It would tell me what type? If I don't know the type, it could type whatever I want right here, any wrong things and it will show me suggestions. So right here I could pick date or daytime or daytime immutable. Okay, let's go for a date. Simple as that will daytime since it to do. And it's really sensitive one you created than when you finish it. So daytime hit enter. This will cannot be No. Yes, other. No, the property they do, Donta daytime cannot be new. The next property is the description and just validates. So no, If it moved back to the entity, would you see that we have new stuff created on one of them is the description that will be creating the migration file and to write that I will be doing teach babe in council make and the c diff entity of the migration hit enter and everything is fine. So we have newly created version in or version file under the migration folder, and we simply need to run the PHP been council doctrine migration. Migrate them. Just copy this to speed up against some seconds hit, Enter and everything is fine. It? Yes. So you are getting this error, actually, because the full value is not valid for a date. Okay, so to fix this, there is two ways. Whether we do without the generation off update manually and other thoughts fields with the default value. Set it to validate or directly through. Ah, this migration file. So you didn't just check that everything is fine elsewhere. You could do the following as I did the right here. So in the each, Kahlan, for example, when we have daytime, we do said this option and the default value to this validate. Okay. And after that, we need to generate a new migrations. So again, in the terminal, I will do Ph Bay Been console on calling the maker maker Don't migration. It will generate a new file. And right here we could run it. Let me just to check the migration file. So which is this one? And we do see Let me just check that we have that value valid there. Ok, there is these backsplashes that could created trouble for us later, so it's better to remove them. Andi Also, this is the problem because it's using actually these a single quote. So to fix this, we could back Teoh our file and right here it's already own a double quote. So what about getting rid of this migration and creating you one? Okay, let's check that. So this is a corrected new migration file with that back slashes. But anyway, let's try that. So if I trying dry that it Yes, OK, we still have a problem with it. What is not executing that valid migration file? Because Onda, very ago. So we simply updated our ah, our let's our database all migration first. Then we persist. That changes to the base. You then using doctor migration, everything should be fine out. If I do refresh this, select all I have that validate. Let's say in the default validate inserted and everything is fine now 50. Working on the UI - EP II: so no firm move back to our application that we literally forget about it. I could display now the created date, the due date, etcetera. And we could also display thes dates by older etcetera. OK, let me just scared off all this mess and just stick with this, okay? I'm just opened that greeted page. Where does it went? Toe. So it's ah, the index dot html. And here, as I said, I could added the date back to the design, so it's kind of divided into sections for the info on we have here the details about it. Okay, so I'll have to great or upper inside. There will be around for now and a cold. Okay, now called actually, but inside it will be having the call for my this code. Okay. And right here we will have to Dev's lives. Number one, It will be a call off eight. Cool. I call 12 called lg. All right will guarantee that everything will be fine on the mobile device on. I will be moving this span inside the Dev right here based it on and also be displaying more content for now. It will be the date so I could do the following. I will do a span. This would be the date. So date for now could do to do that. Date or created date. Read the date. Yep. Refresh on expression. Throw catchable error. Object data could not be converted to string. So since the created date is a date, probably averages. Let me just say this. It's a data we cannot display directly. And if we do so, we will be running into a trouble. Black. So let me. I close this too. So an exception is being do that because this cardinal be converted to string. It's off time. Daytime. So Twig does offer a solution for this, which is the date? Call it pipe. Okay. So you simply could do em The why and your problem will be gone. So they go. We have the dates. Set it to 12 20 17/70. You could added, like, common case. Why that you could have the full they displayed. Okay, So the next thing is what? Uh, what else we could display? Yes, the description. Okay. Let me do randomly. Explicitly added a description to any any record inside this study buddies. So right here I'll be writing a quick SQL query that it will owe me to update like description ordered some tax to be displayed. So the update, then starting by you to me who flee could pick up eso back, slashes you to me. Symphony yes. On will be updating the to do OK and this should be fine. So I'm having this little room text right there now if I moved back here are we still did not implement that in the html so below this A span I would like to added a B tag And inside it, I would say to do dart descriptions simply as that on There you go so we could style it a bit more for sure. And the proof that the description is shown correctly, but it's not really as it is on the descriptions. So what about give it a bit more styling? So gardening class here. But instead of being able to go to with Dev, okay, and this could be a colored live. Ok, so I think I missed the order off the element tags. So this is the death. It does close right here. Okay, Okay. I start under the class McCall, its description back to the CSS file and inside that inside this rapper, I create a new rule For the description. I'll go phones, family. Let me just grab burn. Too light. Oh, I broke something in the HTML that was closed right here. This is the death, not a pig. Okay, this is light. No, this is not like I would like to fund fare from tweet, Actually, 200. Okay, that's better on. I will do a bit off putting in modern. I would like to stick with its drop classes and stayed. So right here, I will do MT. Top two M V. Two margin, bottom two. Okay, great. Andi. Quit. Added. Also takes under nine or something or rapacity. Lower capacity to 18 for examples. And yep. So this is description ordered. A bit of putting to the left side. So, Doofy, l four this It would be like distinguishing from the title itself on. There you go. Pretty good. Okay. We could stop at this point because of the point off this tutorials don't really have to create this harsh chemical stuff and details. But now I would like to jump into this section, which is the form and creating new full. All right, so moving back to closing this first. Andi, I'll be closing this one to this one, too. On we are editing the great. Yeah, so we have a plenty of things right here. We are under the slash added. OK, so we are loading off form. Who is the following right here under the entity forms. And we have this to do for you might ask how it does not contain the the forms. The new created fills its simple because it's not updated yet. So first I have to remove this to do. Okay. Great. Now head back to our terminal and right there will be doing pH b being console. Make fall on. Tell it that it will be called to do and it to be using the to the object. And there you go. Everything is finer. So no. If I move back to my browser refreshed, I do have the newly created forms or inputs and very valid and available to be start working with. Okay, I have two added. Also, submit bottom. So to do, type and duplicate this line or like two other submit. Let me check that. Okay. Must be started to a type. So to be submit type from make sure that we did imported from the correct path. So it's from the form extension. Great. Now federal fresh. I have that summit. Okay, now let's fill some data. The priority will be high on hit. Submit. Okay, please. Under a valid email right here, it's requiring to be an email. So email our email dot com submit. Okay, there's no validation message. This is would be the purpose of the next minutes, but I would like to check back. Let me open this into new tab and check if there is a new league created email. Very go. So we have newly created from the each form. Everything is fine. We have this description on Great. Now we would like to add that edit bottom. So to edit it, I would like to add at the bottom right here. Call it and it also we need added the D late. But here also, before moving forward, I would like to add it text area type glass, Great. So know if they do refresh, it's better and it's attack Syria 51. Flash messages: so right here our form do his mission correctly. Except there is no output for the user telling him that the mission was done successfully or something went wrong. So we are using actually PDO in the background. And if something wrong, then PDO will throw that erode that bigger that something went wrong. But we would love to display a success measure message to the user. And right here here come another player. Which is the flash, actually, messages from the symphony. So right here. I would like to wrap everything into try catches statement. Okay, supposing that when something went wrong, we'd like to define it will display a custom message, so I'll do Troy and catch. Okay, So catch will be an exception. And inside it here, I would like to paste that code The previous go that we was working. So I just missed something right there for Mathis. What's wrong? A dollar? Yeah, so on and right here at his hour code. So yeah, I'll just under the typing to it to avoid this kind of problem, they go Great. So right here I'll be calling dollar this and a flash. So the type first of all would be Let's go notice on the next Thanki is the message itself . Like your changes for your to do is recorded is recorded Great. Don't forget semi column right here Then the next mission is inside the HTML tag. So I write he inside out to do somewhere up Let make duplicate this row aisle created all created cult 12 inside it that would contain our message. So right here I could do for so normally will be having, like a lot off flush messages. So, like an object through the entire application, we need to select our exact messages the specific ones for this Pedro for this action and display them to do that I'll be using for loop yet again. So I'll do four message and up dot messages or flash messages story clutches and will be selecting notice. Nothing. Get to close the four loop on and four on right here. I will just say message the stick. Simple as that OK, fatal fresh check that everything's fine. Let's say the priority. The name, the status, the date on. Let me other than me. Hello world. Hello World right here it submit and your to do is recorded, displayed correctly, Except we need to other the bit off styling to it, that it could get much better and have better style. So the class I'll go for flush notice and let me refresh this page again. Okay? We'll probably I will use the alert alert. Success. Okay, now for the refresh. There you go. We have this beautiful, nice message. I will improve the best I would do putting too margin to And this could be a bit more beautiful. Your recorder to do is recorded. Okay, Great. So that was how to define a flash message. 52. Setup Bootstrap accordion: so to speed up things, I made some changes into our template and into like, the website design. I've updated pre much a lot of things, but nothing really important. But I would like to share with you this, like sectional, part of the design where I needed to have the query and boots drop pushed up JavaScript. I mean to have the neck Odin right here. So instead of displaying them open and lacks, I would like to have an accordion. When you collect, you say details on the bottoms to take action on that specific record. So what I have done so far, it's simply running the script inside. My terminal on the script is pretty simple. So it waas on P m e boots. Drop G query. Papa G s and Dash dashed after school them to soar them inside the development dependencies . Now, if I move back to back Asian Jason, you will say that I have a new dependencies added on their ego. So we have dependencies, boots dropped equerry and proper Js. Everything is fine now and we could go with our total. You're so also I did import them inside the weapon gs file convict? Yes. So require bits drop. And I defined accounts that inside it I destroyed the query. Ah, blagging off a plug in? Yes. Okay, so the next thing is including the boots drop of accordion. So to do that, I could speed up things probably to not show you, like, use a list of stuff. So what so I'm going to do is just jump to get bits drop. And from there I will copy stuff about the accordion. So now if I do refresh, I hopefully could see accordion working properly. Except we still need to enable javascript inside the Abdo GSO. They go right here inside the up dodgy essence steed. I will type the following code. Okay, Simple as that. Now, if I do refresh my page, I will have accordion. Okay. The missing part that I did not import this up from the build site. Okay, that we don't not see any changes. So inside the base, um, basics Tamil, I would like to room move to require that voice. I would do script. SRC equals two. Sure, abusing a sets. And the sets will be pointing to build slash gs or directly slash after Js up dot Js On this point, it's a good advice relate to check your in creep point this files, right? So entry points don't. Jason will tell us what file must be loaded in our application. That fit with what? Back configuration? That Thanks. Good work and run properly. So it does tell May that we will have to load these three files with the runtime, the vendors ab dodgy as on the Abdo. Jesus. Okay. You might ask me from where they helped do these three files came from. The answer is back on the Web config file and on this specific method Oh, this property or part of me to split entry chunks. What happened here? Let me just contra click it. Does there say that tell we're back to split your entry chunks. This will mean that instead, if editing one script tag to your page, your service side code will need to read the UN three point Don't Jason file and the build directory to determine the multiple dodgy s and CSS files that should be included on each entry. So pretty clear and pretty self explanatory. And if you don't like this idea you simply command this and still the server Revlon. Run it again. That it could read its configuration. And finally one more fixed before going life, which is giving a check again to the entry point. And it does said here that it need also this room time Georgie s and again from Well, the hell that does this came from. It's likely from this enable single runtime chunk. This method is responsible of generating the wrong time largesse. Okay, so let's stop right here and import that wrong time and just respect the order that is written inside the manifest. So all picking the wrong time Then after that would be importing the Abdul Gs refresh. Everything serves up and let's give it a shot. And welcome back. You are live with the accordion. 53. Fake data with Fixutres: Okay, let's get going with our video. And I would like to implement the accordion to fit our need. But first of all, it seems like we don't have any record inside the database. So we need to under the condition that show that there is no record inside the database to the user. Because now, if I do hide this section, that is containing the accordion. When I do refresh the page, there is nothing displayed and the user does not have any idea about what's going on right there. So we'll go ahead and added the if statement from the twig word. Look, if and two DUIs and I'll be passing a pipe if you we should call the pipe and I'll do length a bigger than zero or equal to zero, actually. Okay, then I'll be displaying a message. Ah, no, no. Two DUIs for now. And don't forget to close the if statement and if critical Now let's check it out. If I do a fresh now are equal to zero. Sorry if I do a fresh okay now to do for now. Well, the situation it seems like our data bases empty and to turn our engine and to explore the loops, etcetera, we need to have, like, a data ready there and inside the database. And that does not really make sense to record manually. Every time we need to insert something, we have to past, like 10 to 15 time inserting these data over and over again just to fill our database. We have junkie content. That's why symphony did it create a tour called Fixture that low as two great fake data. Mark it. Eight Dave, you call it that could be uncertain inside the database on the lowest to do our work. So to have this fixture available our application, we need to install it as any other component. So again, in the root of our application, let me make this slightly bigger. All the composer required or am fixed her. Okay, You could simply could remove this section. And that should be enough hit. Enter on, let it do its work. So now it's time for flax to fetch of these Ah, component and deluded. And it's told and can't figure everything for us that we could start doing. Our things were fixed. Okay? Mr. Flex did his job correctly And now it's up to us to start working with this fixture. So the very first thing is to create a fixed. What is a fixed? A fixed A is simply a PHP class where we do create objects and persons them to database simple as that. Right. Okay, so let's go ahead and create fixtures. So under my SSC folder, I'll create a new folder. Okay? Just refresh. Something happened there right there. And we do see that already. Mr Flex, it did a great job for us ended. Create this data fixed a folder for us and inside of the does great. Also an example are called up fixture the containing a method called load on. The best option is to create a specific fixed up for specific section off our application, For example, when we do great entities to do is actually we need to create fixed up for the to do entities. So let's go ahead. And I simply duplicate this to avoid typing code again. So instead of up fixed, I always say it's to do fixer. Okay, added that and right here, make sure that the name space is correct. And don't worry about these calls because we do need them. And right here, I just renamed this due to do. Fixed their aunt. That's okay. So right here. First off, all I would like to instant shade to do so I'll do to do equals to you to do make sure that we do import the entity, not anything else. And we will do the classic assignment. So I would do to do set on all the sets, actually, So I do set names that properties said something else, All the properties. But here we are looking for a solution to insert multiple data, so we need to use a for loop. Okay, so right here I will do full well, actually, below this, I'll do above Sorry, I'll do $4 e equal to $0 e lower. Then let's suppose 20 and I will insert dollar A plus plus implemented until it rich 90. All right. We could do if and if. Okay, right. So what will happen here each time? I will create a new instance off this to do. Then I will make sure that I do persist it. Okay, then we have this manager that is actually our doctrine manager on the team manager, as we did inside here inside our controller. This section is replaced simply by this one, which is actually coming from the espouse it perimeters to the load, which is by its type. It's an object. Manage. Okay, just to understand what did happen here and where this flush came from this manager. Okay, so let's go ahead and implement our logic. Okay? So and I will do SAT user, but here I have to also create an entity user that could be assigned right here. Okay, so right here I will do needle a user equal to new user. Make sure that it's important from the right entity that is up entity, slash user and I will do the same thing. So do dollar user set name. Let's suppose it's may again alway blasts of confetti night that jewelry to have, like, a general name or yeah, just keep it simple as that. And I will also sat the to do. That's not the case for now. I believe I did not set it to be. No, Hopefully I did that and I will do set the email and I will do my current email. No problem. To be repeated. Mahmod are tee Yeah ho dot com and outcome Catty night and the large A Whenever it's not a problem. Okay, so it seems good right here. Andi seems not finish it for the to do, so we need to add it to do. Let me added a bit of space and commanding, set the user and set the to do and great. And so they said the title. Let's suppose this is another. Okay, So also, I would like to recall this set to do somewhere above the to do statements, and I would do user or just face that user user set to do and I'll be passing this dollar to do. Oh, great, great. And I could get rid of this one and just I would like to keep this little sections on. I will do persist the user. And to do so, I stopped by resisting that todo. Then I'll persist the user after it, user Great. After that, we need to flush everything to the database 54. Execute fixtures: So it's a symphony to take care off. Looting these fixed er we need to run the following command. So do pitch may be in council. And instead of make, I will do doctrine. Since we are doing databases stuff out of the doctrine dot fixtures don't float. Unload Is the method just hit under Olympic clean? This he don't and carefully you do me would be Persian. Do you want to continue? Okay, I just missile another property, which is set priority. Now if I do run it again, it must be all good. Okay, but to be sure that all good, we need to check our database. So inside our schema you do a symphony on Let's go to Today we have 10 records and we have 10 user And seems like something went wrong because ah, we did not rich the 20 Rocco Recode as as we sat inside the fixture. Where is it? So this one we said that must be okay. Oh, say I said it just be from 10 to 20. And that means that everything is fine. And this hour fixed her running properly. And we have record inside the database and you're free to go ahead and generate fixed her for other, uh, entities. This is your task before the next episode off this Syrian. 55. Deal with Accordion dynamic index: So after we did insert all these fixture inside the debates, we have something that valuable and we can test our application. But for now, there is a problem. So if we click on any off them, it does collapse or close all the other ones. The problem. He is actually related to our HTML tags. So if we look carefully, we have a data target right here. Said it to collapse. One. If we do search on this collapse one, we do say that it's sided here as an I D. And since we are inside the loop, then will be having multiple exactly 10 record with the exact collapse. One idea. So the solution is to make this I d. Dynamic and for sure, this one too. So to have a dynamic city insider to do or a full loop, we need to get that index. And in symphony we to have this index, we have access to a loop variable right there and inside this object. Actually, it's another property colored index that is holding the index. So if I simply keep that and do refresh and despite it does show may that index from 1 to 10. So our mission is pretty simple. So instead of keeping it as default, will be cooking, donating that I d and everything should be fine now. So now if I do a fresh look what happened, it only close this specific or collapse clothes on or open the only specific one that we do click and does close anyone else that is open it. 56. Add action buttons: So the next thing is to get rid off these ugly borders. Since in the design we have only Ah, boredom, bottoms all that is a beautiful and minimalistic. So to do that, I would like to go ahead and start overriding the route. Our the card story is so if you do inspect with you see it first awful lot we have ah, border bottom Saturday 20 right here. And we have this border. Set it to one pixel with that light colors. So I simply stopped by copying this one and ready, I will do card and I will explicitly said the border bottom. First of all, let me just spaced that for now. And I will do border, border, bottom and border with Set it to 001 pixel and zero. And for now I hope I could not. I will not use the important statement to force the statement and it seems like I have to. So I do important and just give it a second. What's wrong here? What had happened? We have because we have border bottom, set it to, um do known border rapper car it border bottom. Uh, what's but it only take a fact on the 1st 1 Because with what? What about just doing court? Simple as that other ones did not have. They are cards too, but I don't know why there is no border. I a go Not Okay. So I have also to copy these pseudo selectors just to force my things. So I do refresh now. There you go. Great. Okay. Perfect. Now I would like to improve the form size off their sections. So we have front wave bulls would like to sign. Plus that like name to do Name something. Explain the forest I would do to do under school Dash name. So using that with him get moving back to the app dot Syria says, oi CSS on guy was signed. Um, I don't like this phone. 12th Bolt. Sorry. I will make it bigger. So the phone size to ramp for now. Hopefully, this won't be too huge, okay? And yeah, I think it must be more bigger to ram from size. Actually, not style. There you go. Well, that's a huge What about one point I'd like to go to 1.2. What a three. And there you go. This is better. The color elect to light. Like, uh, let's go like gray. Okay. I need to select a color that he is a bit deeper, but not that pure black. So I'll go for this color. Make sure that Yeah, it's after you. I'm not a designer. So we're just trying to learn how to manipulate. This is the important section off this. Ah, this episode. So yet again. If you're not a big fan of this, you could skip to the accepts odes. Okay, guys. Okay, So the next thing is, what is to thio added like style something Teoh a collapse it according when it's open it. So we do know it is that when we do open any of them, there is a class that does tuggle between collapse ID and is not collapsing. So right here, look right here. When I opened one of them, it does go away. There is not collapse it. So you what I'm going to do ease the following. So let me fixer the bottom. Okay. Lets me scroll a bit up. Okay, so we have this collapse erred and does its impact also the parent. Okay, so This is the body. And there is a clause that toggle between are collapsing and not collapsing. Collapse collapsing labs show on the class show does differ. So l just create new property using these classes of the collapse dot Show on. Let's go ridiculously high ground dread. Okay, but we will not keep it right for sure and just testing things. And let's go that way. Okay. Didn't make this color more or less aggressive about this tiny, tiny light cover. Okay, let me just say this again inside the up dirt A CSS. So right here I will be placing that things right there and give it a shot again. Just it. And there he goes. I know for open is that beautiful color differentiating open and And also I'd like to style the open it dub So on there is a difference inside. This one would like to go and side lists one. And we have glass collapse. That does go away when it's collapse ID and we have it. Okay, So you I will do a Sinus specific a class here. So back to the html and inside Let me clear this one and this one says I don't need it. And I'm looking for or the index dot I just clothes in it. Okay, This one. So right here, I would like to call it, um, seed of, but, um, I would like to change to Ah, what about death? I'd like to get rid of the do and change this to a death. Simple as that. And the next thing call up, sir, it is good to sign. Okay, So cool up, sir. Like to re inspect it again. We have this def. That must be D block for now. So the block Okay, this guarantee that we have, like, a full. We're taking the full with off its container on, and I will do collapse. Er okay, collapse or collapse. It and I would like to serve it this close when it does not have the collapse of the class . So right here I will do have to added this first because we need to have a block and and it does not this one. And let's uttered the same background color. We could ah, unite or booed them Are the same property right here. And let's refresh. Okay? So when we do open. It seemed not taken affect because of what? Ah, still much sure was wrong here. I would like to put it an aggressive color that I make sure that always there. So it's not taking effects. Yep. Lego. Okay, So it's taking affect. And we have that Ah, background color Said it correctly. Now if I do reverse it to but color with it select. Let me just finish compiling. Refresh the page. And there you go. So when we do have been, we have this highlighted beautifully. Okay, so the next thing is to remove this putting since we don't need it. And it does make our application ugly and actually is getting it from this top to do header is this one. And from these PT and PB 22 we could get rid of them or actually get rid of all the paintings. And I will do move these classes down to this one. Okay, then that would make most sense to us. So we have this whole block and we need to put the stacks to the right or the left side, actually, So I believe that is a classical text left. And there you go. So pretty great. I'll do right here. Text left. Nice. And how do fi tl bathing left to to all this update the whole padding to to to avoid any complicated coat. Okay, great. So I know if I do open, we have this one. I am We need to add the edit bottoms. So Reut here below the date. I'd like Thio added vertical lines. I do each are and I will do you l ally. Let's suppose this will be the edit. This will be a slash it it and would become cat uniting of the idea later and the other one would be delete. Okay, great. So we have it's and elite we need to add it and a treff delete. And don't forget to catch tonight slash i d So I will do to do dot I'd get the i d and same for the edit. Don't forget the slash Refresh the page and you say still did not set the draft What's wrong? I because the delayed is outside the a banker link. Great. Right. So we have this Delete it to delay to We have this, uh three delay three. Great. Perfect on nice. So it a town delayed are ready. Just we need to implement the logic to do these things. And there you go. What else we could do? Okay. We need just to have a look back to the design. We have this date with that beautifully. And the lion that we have this Ah, as we said, it will be the state. And when clicking on this, it will be a setting it has done. So let's go ahead and play man to this. So we do have this, um, this kind of, ah circle that would indicate the state, actually, as we sat here and we will be adding it it or finish bottom right here that will allow us to directly update, but it it Okay, so right here, let's either another but on a link and call it, uh, clothes, for example. Right. And there you go. Okay. So I'll do class equals to have. And this one display in Lyon block Nice. Let's see what never does give us. Okay. Nice and classic ALS to margin margin. Right. Let's set it to one. And this will be enough that we could have Ah, beautiful space it, but seems like it's not working. And there, too, for on the in line block and great. Very good. So we have these links. What about putting them to the right side? So text will be right? Andi Seems like that did not take effect. Okay, Okay. Content a line, right? Actually content a line, right? Or contempt, right? I believe so. Contents. There is a class for sure that is right. But I really ignore it for now. I forget, actually, but I believe it's contempt. Write something like that. But anyway, it's not a big deal. We do have them right there. Okay. All right. So the next thing is to enable, like an Oto open it section right here. All right, so to do that, it's yet per simple. So I simply will do inspect the 1st 1 with any off them. And I will baking a class so that alot it to be open it And this class is show this one. So if I just take it away, it does going away. It does hide it if I put it back in the show, so make sure that it's for the collapse. So right here The collapse one show and I will set this two in if statements I would do if loop dot index equal to one. Who zero. Let's go for it. Zero I will, though else on. And if I hate that show displays show right there. Okay, that seems fair. What's wrong? So I will leave the if statement. Although if loop dots first and became about this is the first iteration, then don't forget to And if Okay, then I will simply display that show class. All right, Now, if I do refresh, it's it's actually working. And you may say that we have this background correctly. Said ID What's the problem here? We need to go beat deeper on. Just said this inside the Java spirit. But I just would like to show you how to do an if statement inside, like a string of class with something. So to do that, I will be using this area expanded that is, by default, said it to true. So right here will put it to be and dynamic. So whether true or false, the panic on a specific condition on this condition will be whether we are on the first iteration or not. So to do that, I will do if loop again dot first. Then I will do Drew right here. And don't forget to close the and death. Okay, this should define a So if I moved back to my brother and do refresh, I do see that I have the 1st 1 You pin it correctly before moving on. If you look carefully to the design or to the 100 html design, it does seem like the gray by ground is applied everywhere. And it's not, um, fit in the rule off when you are open, go dark. OK, so this problem is actually coming from the rule The following rule this one body rapper collapse or that does not have a collapse it and all of them doesn't have a collapse of any Dave. That's not collapse. And then it will take this role. So to fix this, I would like to remove this parts and replace it by a new property or another selector, which is based on the attributes. Right. So let me just make sure off the class name. So this is a collapse, er and I'll be targeting this class by an area. Okay, I'm just get rid of this to be boy. The area expanded when set it to drew. Okay, so, no, if I do refresh again because it's a cash problem, we do see that everything is where we want it to be. The 1st 1 is great. The rest off one off them are just white background. Now, if I do Tuggle than everything happened as we were not to be happening 57. Implement CRUD Operations: No, let's go ahead and implement logic for our buttons. OK, so first of all, I start by creating the edit methods. So I'll move back to you to me. And I believe I have an edit statement who admitted somewhere created there. So this is an editor to dough, and it does load a specific form. So I'd like to use this name to boot throw or just simply using this todo because there's two options where they're going from base one using the path method. Like so both me and for Amir was them as a right right here. Or simply use of the classic way using this one. Okay, simple as that. So let's go ahead and test it. If I do refresh and hit edit, okay, I'll be landed into this page, and everything should be fine now. So this is a mother Heidi. Let's go and grab any random texts from all around the Web based them, or this seems to be a description. So it's pretty long and react, for example. Example right there, priority should below status to let's set it to Don and let's update Ah, this due date, we could set it Whatever you want. Let's update this to 2020. Aulas, go to October 20. My birthday. That would be 20 on and it's a bit so it does not show anything because we did not define any, like, Canda flush message. So But I would like to move back and we do see that everything is updated. We have the react examples We have this newly created and we have the 10 2020 19 newly date . Okay, So was go ahead and implement a flush message for this sections. So to do that, First of all, I'd like to make sure in which template am I. So I'm under the route to do, which is which is actually let's close this one for now. Andi, I am on this template. That is to do dot html the twig. I did not added any message to this one. So I have two other if submitted out, like to copied from somewhere else, which is a flash message to speed up the process. Just simple as that. So I will go to it. It it to do well to do edit this one and right here I would like to find that added the flesh to the whole application. Now, if I do hit, submit and I have that is record corrected and had let just would like to update it. Quick things which is here f alert. It must be alert without any need to this p two and major in modern to I'll just give the modern. And if I do refresh ago, this is slightly more beautiful. There's no need, actually. So instead, off em to hold up to added margarine bottom too. Okay, enough. I don't a fresh There you go. So this is this is better on it does tell us that everything went well. Okay. You know, if I move back, I have my stuff updated. What about bleeding that? Okay, so we need to implement this late. It's not there anymore. We know there is not created actually yet. So let's go out and implemented, and we'll be doing this following claim we close this for now. So this is our delete. So we could simply delete to do point them to vote ling can would be good to go. So delete going to member would lead to do and plus the I d to this method right here, and everything will be fine. So just get you a reminder right here. We have the entity manager. We we do return that i d who check it does exist. It does not exist. Actually, throw this measure message. Andi, if does exist, just do the remove. And don't forget to and display that message right here. So right here. I would like to added this message which is at the flush notice to do dilated correctly to do deleted successfully or correctly whatever you want correctly. Okay? No, let's go ahead and do a fresh up. Yes, you have to do thinks from the beginning and to do remove it correctly and everything is fine. But the problem here because we are returning new response there is no template looted. So we could implemented direction to the previous page and write their display the message . And to do that, it's yet pretty simple. So we cede off returning in new responds. I would like to do the following, so I would do return. Dola this redirect to root and I will be passing the this this like landing page route or home route which is named you to make. Okay. Great. And that's it. And inside that to do I would like to added an interceptor or a handler for the flesh message. So yet again, I'll be cooking that from this, uh, this comply it. Which is that to do the HTML and simply grab this section in, Place it inside the index dot html right here, for example. Okay, let's go ahead right there. Nice. No. If I move back and refresh my things, I have to do related correctly three times. Okay? Because now, if I do delayed, I have only one. If I do refreshing another time, it does go on forever. 58. Update: Close a todo: great. Okay, The next thing is to close this one and closing mean turning the state from, um, from bending or any other statement to to don closed so close must be implemented. So right here, let's look for any update to do so we have this update and we must simply us crop pretty, which is pounding or status, actually to a dawn. And that's it. OK, so here the reason Two options whether used it to do which is this one, actually and simply it it leads to change it to actually say Just change it to Don, like so or creating who on a whole new property for it on a whole new method that handle that and only update a specific attribute off our record. So the first thing I would like to check when this bottom or this circle turned agree in which his statement it does turn to green. So by checking inside the index dot html, it turns out that I'm using the pending statement to set that to a dawn that apply a green color right here. Okay, so it seems like this is not logic. So I would like to change is to don when we have done, then this must be green. Okay, that makes sense. And it seems like there is no green at all. So let's go ahead and turn this to dawn. What about type thing? Done like So this will would be logic. I will be correct and incorrect because we have done but its upper case. So I will do fight lower and that's it. Perfect. So we have this green color if it's a green in my eyes and it doesn't decay that we haven't done. Okay, we would like to implement this using a click on this one. So I will start by creating a new method. And actually, I'll be coping the delete. So since he does have pretty much everything and has also their directions So l came here based that and update this. So be close. Edit close to do. Sorry And 1000 I d close and it and close Add it close to do. Come on, focus. Close Did nice. Everything is fine here when there is nothing just returned this or throw to be correct this error elsewhere, it will be updating thought to do so. I would do to do, Set said. Status to Don, and that's it. The next thing is to just flush, and everything would be fine. We don't need to resist because it's really there are 92 managers now about it, so it will flush it. The database on update what's needed to be updated and returned this message. But it must be to do updated correctly. And we could pass the i d dollars Heidi right here. But just make sure that you are using the double quote elsewhere. It will not work great. No, if I do refresh and, for example, pick this one hit close, it does broke because it's pointing to it it. So you have to update that link close to do back to index and ways that close. So this is the close. This is a your pocket. That's the delete that this is the clothes nice. And now if I do refresh again on hit close for this one due to do seven updated correctly and we have that green colorless does that for another one, and they go. So the next thing is to disable, for example, close. You cannot close something that is really close it so I'll do the following. So the best solution to disable this link the clothes, for example, is to get rid off the H ref when it's already done. So to do that, I will do the full link. Okay, Okay. So closes day blood right here. And it's enabled right here. If I click close van, it will be also disabled, which is amazing. On what about adding class. So let's suppose I'd like to added a class like borrowed. A Wonder line was something like that. So to do that inside this classes statement, I will added a condition. If this status equal to done, then I will other this text overlying and the stakes of alliance simply apply text decoration with a line through. And that's enough. And, as you may see when it is disabled than there is an overline a through line. But there's dollars that this eyes disable it, and we could go a bit more within a passivity filter to set it to 450.45 What, what about two? And there you go so less capacity with an underlying over aliant, and this is better for the U I. Okay, so for now we have this bottom working correctly. We have the close working and we have the delete working too. 59. Events in Symfony: Hello and welcome. Everybody, Thank you for being here so far. I'm really happy with my stone. Were Richard into our Siri. So we had a lot of fun dealing with all the component of symphony. We played around with the crude operation and we did a lot really off good and amazing stuff. And now I think you are ready to put another gear on and move to a bit more advanced in future. Don't be afraid. It's not really hard is not difficult. Just follow me long and you will enjoy this. Think And this topic is the advance on Symphony E will be discovering the event Dispatcher and event listener will be comparing them and play around with them in other ways. Okay, to give you pretty face give you a general idea why we have these kind of events on symphony. Let me just read you this example. I really like it from the symphony website. Okay, them just drag this one and let's consider the real world example where you have all you want to provide a plug in system for your project. A plug in should be able to added the method or do something before or after a method is executed without interfering with other plug ins. This is not an easy problem to solve with single inheritance so on. Even if multiple inheritance was possible with Paige pay using, traded, for example trait. I mean trade by this T r I t. OK, then it comes with own drowned drawback. So we will jump and we are run into big problem off maintaining out code and keep things clear and easy. So right here the symphony event dispatching component Implement a mediator and observable design patterns So observable, maybe a family. Your password. Key word. Actually, if you are family or with Eric's GS and there are X pattern in JavaScript and no debts. OK, so these are designed buttons to make all these things possible to make your project truly extensible. So take an example from the issue. Typical component. Once a response object has been created, it may be useful to a lot of other element in the system to modify it added some cash to headers, for example, and before it's actually use it. To make this possible, the symphony colonel throw an event. This is the K. It will be using this later. Hair is how it works, so this is really self explanatory, and it's amazing three points that explain the integrity off this system. So a listener, which is a PHP object, for instance, tell a central dispatcher object that it wants to listen to a colonel response event. OK, then the next thing he's uttered, or at some point, the symphony colonel tell the dispatcher object to dispatch the Colonel Response event, crossing with it and even object that has access to the response. Object in question. The third point of the dispatcher, notify example like I calls omitted on all listeners that are subscribed to this colonel response event, following each off them to make modification, all read from it or display any content, right? So these three lines does really explain it all. And let's go ahead and see how to implement these listeners 60. Events explained: so the very first step to start working with Dispatcher on Symphony is to install the component itself. Composer require symphony, even dispatcher. So I already done that. But for you have to it that enter and it's salt fetching all the components. Amber, count the stuff that we lose things, set up everything for us and would be ready to go. So I might just council this for now because I don't need it and we could move to the next step. So we have some major players into this micro system inside Symphony. So the first player let me just drug it right here is the even. So this is our first split. So when event is dispatched, it it's identified by a unique name. For example, it more it could be cold like so. So I mean, just the dragon text and it could be called colonel response like so Okay, which any numbers off listers maybe listening to and even instance is also created and passage toe all off the listeners, as you will see later the event object itself often contain data about the event being dispatcher. So right here we're having a naming convention about this event. So with the unique event, name can be any string, but optionally follows a few naming space conventions. So use Onley lower case letters like so as we did number like colonel dot response. Okay, so when a dispatcher notify listeners it pass an actual event, object to these listeners. So we have another big player who is the dispatcher and as the name manage, it will be responsible off dispatching specific oh, various events into or between listener. So this patch is the central object off the event dispatcher system. In general, a single dispatcher is created which maintain a registry off all the listeners. When an event is dispatched it via the dispatcher, it notify all the listener registered with that specific event. And finally, the third actioner or actor into our system is the listeners or the subscribers. So alcohol, them subscribers or listener list earners. Okay, so let me just move this away right here and dro connection between these things. So let's suppose we have our system right here. Let's say this is Logan system and move this right here. This right here and this Logan system will execute any specific X event, for example, We did Logan right here. OK, then we have this Logan event. Okay, So what happened here? When this system process this Logan event van, that dispatcher will be watching this one. So this this picture will do not fi all these subscriber that ive found off type Logan event is being executed at initiated. So it happened that the subscriber or listeners will react to this. Why? It is accusing any specific type off script that we tell them to do. 61. The event listener vs event subscriber: I believe there is a question in your mind. So we said Event subscriber, An event listener. What is the difference? Why there is this kind of to Okay, I won't answer this now, but I would like to answer one single point, which is the performance consideration. One important difference between listeners and subscriber is that symphony core load entity listeners lazily like Lee's eluded on. Ah, angular. If you bright played around with that. So this means that the listener class are only fetched it from the service container and is instance she ated if the related event is actually fight. So another term we will have on Lee that subscribe already for us. When this specific event is fire it elsewhere, it will not be there, and it will not be instant shaded inside the service container. That's why it's preferable to use Entity listener instead off subscriber whenever possible . Okay, I think you just taken enough talk. Let's go ahead, please. And who thinks in action and cooed, I would like to see code. I know you say in that 62. The event listener : So finally, first off all the event listener how to create this event listener. Okay, well, studies simple. Just go to symphony documentation that you find everything okay. Just getting. And yeah. So to create an event less than the very first thing east to move to the SRC folder and create a folder that's called it SRC. Oh, sorry. Let's call it event. Okay? Hopefully I won't spell it would spell it. Wrongly event lis tenor. Okay. And inside it I will create let's say, a new page, because so that I would call it Colonel Exception. Okay, hidden under and old. Good to go. Okay, so this urinal exception will be listening to a specific event, as we said, and he will execute some tasks. So I was a very simple and a quick example, and good one actually start with is to other the listing for the exception. That might happen into our application. So an exception mean when we run into a 404 errors when we run into something that's not OK , that we cannot load any class. It said we can intercept that this is an amazing war. Describing what in a like subscriber or listener do and do action whether displaying gold chain jingle playing around with that response. Okay, so we'll be listening to any exception that may happen in the kernel. Right? So right here I will do public function, and I would call this on caramel exception. And this name is not like random. We are here telling the exact name off the even thought will be fired. So this is colonel exception. And we are adding this aren't to tell symphony that who are executing this method on when this colonel exception, they a cure? All right, so right here, I would like to do die. Okay. At this level, nothing will happen because symphony do see this glass, but don't know where to use it, how to manipulated. So hair come another player. Very important. One which is serviceable to jahmal file. So let me just jump into service or TML and right here will create a new property for our class or for our listeners to be more adequate. So right here we'll start by typing app, slash go back slash event list inner backslash and let me just drag it to make it simple. I just drag this name space right here to be more sure that I did not type something wrong . And our drag this class name, that's must be a common case. K. Make sure that it's complicated us where it will not work. Okay. Yet again. Okay. And the same for the file. Name must be common case. Great. Cool. So the next thing is to tell what the tags so tags mean when aware of this class would be use it. So let me just do tags, dots, and I'll be passing the full wink. So the 1st 1 is the name. And look what happened here. When I do this single quotes and I type colonel colonel dot Give Aunt, Listener, listener and I will also the IV aunt. It will be a caramel exception. Right? So you do remember that we said it must be a verb. Look what happened here. They visit all the possible events that could be fired from the colonel. We have response, controller controller arguments finish, and all of them are verbs. So let me just put this in tow, Colonel exception and we should be good to go. It seems like working correctly because the name space dragged me directly to the file. And I'd like to it could remove these single quotes and make sure that this is working correctly. Event listener. Perfect. Okay, now we need to crash our application. Let me just check that. Everything is fine. Perfect. Nothing wrong here. But when I do, for example, this wrong you are Look what happened. Okay? It seems something went wrong here because it's not intercepting my coal and they go, I'm used to spell these things. So this is white star running properly and a fighter refresh. I'm having my message correctly displayed. 63. The event subscriber: No. Let's talk about the advance subscriber. And to have a good example, would be doing the exact same thing as we did with event last night in the previous video, and we'll be listening to the Colonel exceptions. So the deal is a bit different. Instead of Event Listener folder, I'll create a new event subscriber folder Do event subscriber. I like the name because it's much more easier. Do not miss is spelled subscriber. And inside it I would like to create a new BHP class and I call it Colonel Subscriber, for example Sub. I think I misspelled Kerner. Anyway, I just stay with Colonel Cardinal. Yeah, uh, perfect. And have to rename the file to avoid loading problems. Perfect. Right. So the difference between the event listener of the event subscriber other than performance that the event subscribe choose which event to subscribe to. So the first thing that is different that it does implement the event subscriber enter face from they should to be component event subscriber interface. And right here, since we're do implement this interface, we need to use its methods. So right here, if I do ult control or I'll enter it will add. It will tell me to added thes Gandalf, Um, over two of ride the methods from this interface. And we have this get subscribe event, and we have this beautiful example right here illustrating how to use this method. So right here, let me just get rid of this command. And I will do return an array. Actually, that would be containing colonel even wants. And from this current events, I'll be listening to response control, etcetera. I'll be specifying two exceptions. Okay, so be listing all the exception, but will happen. And I will be assigning this exception to what method I would like to define that will be humbling this exception. And these method will be this one method alm or method will be implementing inside our class. I'm just remove this, that it's simply from May to navigate up and down. Okay, so this will be an array, actually. And the 1st 1 will be another array. That containing the method. As I said, So let me call this show error message. You might say where the hell did this came from? It doesn't come from nowhere. It simply will be a public function inside our class, that is. Name it like that. Okay, so it will simply dump something wrong. Hop in it like that happening. Okay. Then it came another property, which is the priority off the event. So in a given subscriber, different method can listen to the same event. The order in which method are executing is the fermented by the property called priority part A meter. So we could set it here to 10 for example, and the higher the number earlier. The method is acute ID. And to have a better idea about this, we could use our terminal to depart the list off event dispatchers that are listening there to any specific events. So to do that, I'll do Peschke, Ben council and I will do d bog. And let's go for the Colonel exception. And it will show May all hopes all the listeners are listening to this kennel exception. So if at enter, because I'm just having an error right here. So if that there you go, just really there again, it will show me that I have all these dude listening to my event. And this is show errors is one that is defined here has a 10. So as I said, the bigger is the earlier. And the town is the bigger for this. And it will be executing the very first. And I could stop the propagation off the event right in this one. Okay, so let's go ahead and test this out. So before that, actually, we need to tell our service lower. But I have this colonel subscriber that is doing this kind of things so yet again, as we did with the event listener. Let me just duplicate this one right here. And event listener will be event subscriber. It's so Skopje the name to avoid any trouble. And it will be a colonel subscriber. Make sure that the name just is the same. And institute event listener. It would be event subscriber, right? And we don't need to pass this event I because we are defining it right here inside the close. Ok, time for truth. Let's go and break down our application. If I do refresh, something happened wrong. And as you may see, a year, we have to event listener event subscriber firing of the same place. So them just is activate that that you could see on Lee the event subscriber. So if I do refresh, I'm having the message back. So we're not killing the application because here we had to die right there. And we have our message. Something went wrong that he's actually defined inside this subscriber. 64. Docrtrine event: hello and welcome back. So everything want well, our previous example. We discover what he's the listener, what is a subscriber, and we implement a simple basic examples intercepting the exception from the colonel. But you may would like to try something else different and the things that would like to apply unto our application example. We have it to do. So let's superbly, I would like to execute something like sending in email or the canvas have any action that I would like to execute on a specific lifecycle off my entity, whether persisting or baiting whatever. So in today's video will be using the event subscriber to intercept the Post possessed. When we do present something to the database, I would like to execute something whether Dump were sending email, as I said, etcetera. So right here to do that, I start by creating inside the event listener. I created it to do listener. That is simple class PH. B. That's it, contained nothing. Just the name space and there is no method get integrated. And I would like to tell the symphony service loader to handle that things. So right here I start by typing the name space. Absolute event listener. And I would like to load to do event listener. Okay, It seems like I need to grab the name manually, so it's to do listener Andi right here. Make sure that everything is fine. Great. Now here I would like to define the tag, all the tags, actually, as we did previously. And instead, if the colonel event, I will be defining a doctrine event. So right here will do doctrine, event listener and the event that I will be intercepting will be the post they resist with a capital P. Okay, so this self explanatory name is explaining itself will be intercepting and executing an even amount when we do boast a person's when do post persons to after everything went to the database. Okay, then we could also use the pre Paris ist. But we could explain this later on this course now we could move back to our to do listener and right here I will start by creating a public function and it will take the name as you make as a post persist. And this way symphony. We know that this event, when it's fire it than this and listener will use this method to intercept it. Right. And we could just move on and create a very basic example. For now, we won't care what will pass right here, but later will go back to it. And right here let's suppose I would like to dump hello from even Pless Now. Post persists Event listener to do good tape, whatever you want for sure. And let's just try their out. So right here What I have I would like to go again and uncertain you record, so I'll just do any kind of random name, whatever, and slow banding just this kind of things. And when I do submit now, Leuco top into my application. Everything went well, recorded a database. But I have also this message and make this beggar hello from the persist event listener to do okay, lets me in that my record is persisted database and I have this Mrs Mr Story, but I could use it to display it Or, as I said, to send an email, etcetera. But we could go more further with this example. So instead of bussing nothing to this post process, we could pass a lifecycle arguments, which is containing it will contain. Actually, the object persisted to database. So you start by defining off dollar are eggs right here. So it must be inside. The party says and will be of type life cycle event arcs that is loaded from doctor or an event. Lifecycle arcs right here. Okay, great. Then the next thing let me just do entity equal to dolar arcs. And look what I get from that I could do, get entity or get objects, or I go to get object. And from there I will have access to the type of this entity. So what I'm going to do is I will lead check if because actually the problem here that this listener will fire on any resist on any post persistent on the entire application. Alex, suppose we only need to watch that to do event, So we need to filter right here. So what I am going to do is the following. So I will do if not entity instance off and way have to grab it to do entity. Then I will tell him to return. Do nothing right elsewhere will be executing our script. We could do Echo dollar entity gats name gets Sorry. Get Let's go Full title, for example Right there. Okay. So if I do refresh, we have the name inserted, which is this one. So if I do updated and hit, submit again I will have the name inside that echo. So everything is working properly without example. 65. Create custom event: hello and welcome back to this new episode and final part off our course. So we played around with subscriber and listeners. But sometime we need to create something ourselves and the case that we will need to have our custom event spattered all round the application. Let me just give you an example off a customer around that symphony Bolton want came with. Let's suppose would like to dispatching event that fire when user open it to do for anything or just for view. Winner. We don't have such things on symphony. Yeah, you said that you could use when we open, you can find work round. But the best thing is too great a custom event and this is what I am going to show you today. Okay, so the very first thing is to create an event. So to do that, I speed up a bit things by creating this custom even folder on the SRC and inside of days, this to do event class that contain barely nothing for now. And just remove these void spaces and this one too perfect. Okay, so first off, all this glass must implement a specific enter face, which is or specific? Um, actually ec another class. So I'll be doing extend e v count. Okay, then this event must come from the symphony component event a dispatcher. Even so, symphony component on this one. Okay, the next thing is decreed the constructor method. So just director and this constructor need to have a type input attribute Aparna meter that will be of type two due entity, our entity to do so right here I will do a fight to do and I will call it to do right there . And I will need to have a property protected called to do so. It will be hosting the object. To do that will be dispatcher from the dispatcher to the listener or toe the subscriber If that makes sense for you. So right here will doodler this to do equal to door large to do. And since you are talking about an event, an event mean some key and the key is a night. So we need to create a public property public. Const and I would call it name and it will equals two to do again. As we said, names based dot than the verb open it. Okay, perfect. And one last thing. I would like to return the public function that would be get to do like so And it will simply return this protected to do the s and to do all is good. What's wrong with this one? And expected Don't if you are age next draft. Okay, All perfect. Now we could close this file and move back to where we won't do dispatch this event and this is the key important part of our application. And we would like to dispatches this event when we land into the sport of our application under to do and it slash vied. So inside this method, which is the edit to do that house this route, I will be this budging an event. So to do that, first of all, I need to inject the event the dispatcher into my application around. We need to create an instance off the freshly created to do so I will do to do even want equal to new to do even want and look what happened here. If you remember in the constructor of this one, we need to pass a variable or an attribute off type to do so to do. It's really there. So the next thing is to dispatch this event. So I will do dolor, even dispatcher. Then call the dispatch method. So this dispatch method taking the first bottom meter to bay them just jump into it. So the 1st 1 would be the event name. The 2nd 1 will be the event object in itself. So the event to pass to the event handler listener if not supplied and empty amount instance is grated. Okay, so it's require a specific type that it must be evened off type event in this picture. Okay, then this event dispatcher, it's already here. If you remember, the name space that we are extending from is the symphony component event dispatcher event . So all is good. We could now past this one as the second parliament and the first bottom eater will be this name. Attribute that we define it right here. So I will do to do event dark name. And don't forget this Amy Cullen right there. Okay, Perfect. Now if I do refresh to check that everything is fine and nothing is broken Perfect. But nothing happened because we don't have any subscriber that is firing or handling this event. All right, So I will be getting help from our previously created subscriber listener story. That will be to do listener So right here we have of this sports post resist. Don't Don't need our this case, so I'll go ahead and create a new method. So public function, let's go to do open it then right here I will go by dumping some kind of random things. So hello from then you event to do something like that, you could type whatever you want And you could also have it to do right here that we could configure that later. But now let's does this with this set up the legs think is to tell some, funny that this to do or this method from this class is responsible off intercepting this to do Developed to do that it happened through the service door. Twi mo. So here this is where we defined to do listener. This one and I would like to how does a new one other new tag actually, So instead of doctor and listener, I would go to Colonel Colonel listener, current Levante listener, and will be listening to the van that it's cold. Unfortunately, we cannot access the class right here, So I'm forced to How cute it right here. And we said the method that will be intercepting this thing that will be get to do. Okay, Perfect. Now, if I do refresh, hopefully I will see that Mr displayed correctly our sorry does not get to do actually. Must be from this once to do open. I'm serving latte at it. Where is that? So just could be that and refresh and okay, was wrong has been thrown during a runner of the inflators decision because Heather already Sand. Okay, I need to actually change this to an echo and stayed of dumping. And there you go. Hello from the newly found to the rebound and everything is fine. So right here we're expecting to have to do event right here that it would be off type to do event like here. So I will do to do even as a type and I will call this to do event. Hopefully, there would be no confusion between the name and I will doodler echo and look here. So do our event space. And you could get to do. And from there we could access all the properties off hours to do event or to do entity. Actually, Sorry. So let me just get rid of this one. Now if I do refresh, There you go. So reactor is a javascript, etcetera. And this is written right here so that Waas how to create your own event and how to subscribe to it will have to listen to it. So the event subscriber won't be that difficult. You will do the exact same thing just simply by defining Theis event. So I quickly I would create a new our new subscriber that I would like just keep it under this custom event. So right here will do to do a custom subscriber subscriber. And I could just keep forgetting to said that to do toe comma. Case added, and it will implement. And even this, but ah, no, sorry. It will be an event, this special subscriber interface and we need to generate thought method of Reid and right here will be subscribing to the to do IV aunt dot name and will be signing a specific method. I would like to barro this method from to do listener, but I don't know what. Okay, there you go. Then we just take it from there, and I will be passing it right here between curly braces. Will single quote actually under forget to do the Ritter and for sure. So do return an array off subscriber semi colon right here and quickly register this into what is that into the service. So I'll just duplicate this dude right there, and I will do up that Kristen custom. Come on. Anyway, I just grab the name from here. Custom event. I want to do Custom subscriber, and it will tell it to subscribe to the Colonel Colonel. Events of scraper. And what's next? Everything should be fine now. Now, if I do refresh, nothing really happened. Because this is commended for now. So federal fresh. And there you go on the to do subscriber, and it's firing correctly. So get the description. Meaning that everything went well. So I'd like to hello from the subscriber. Duh. But during a space. And how so? Sorry. Sorry. This is javascript stuff. And there you go. So hello from the subscriber All went well and I would like also to reactivate this and thought you could see the difference off these things and others can get united, be are right here and hello to me. So thank you, guys. I'm really happy that you, Richard, so far on this step. So that was how to play around with this subscriber and how to greet your all subscriber and how to dispatch this event. Who freely you learn a lot of things at the end of the schools. I would like really to thank you for being here on my journey. Hopefully, you learn something. You are now really to attack the word off production, and you could start working comfortably with symphony. The code off this entire course is available and get help. You could delude it from the message you receiving or from the command box off this schools . And just really, really appreciate your command. Please leave the feedback because that's really helped me to improve my things. Thank you for watching. And if you are interested in following me on YouTube, I really do invite you to check out my channel. So YouTube Flash Holloway Mohammed Hobby. And right there I generally share content stuff sometime. I do share some, um, some compounds. It's a trust. So I really do invite you to follow me along there. And nice to meet you and see you in another course.