Placeholder Image

字幕列表 影片播放

  • Hello, everyone, and welcome to learn symphony for the four course for beginners.

  • This video will take your this four course.

  • We're taking a two hour, even Start Symphony and use it.

  • We're gonna explain the different components that make sense, a framework and how they interact with each other.

  • First, let's start by explaining what's a frame on and when you should use one frame or is basically each other's just set of tools that help you start making an APB on a very quick way and without having to be with every single leader yourself.

  • An example.

  • With the security you don't use.

  • A friend monkey would have to make sure that you prevent the smallest rest but right in the necessary coat and understanding they understanding the different aspects of that risk.

  • But without the framework.

  • Yeah, but with a framework.

  • Most of the basics, you know, basic and when known threats will be handed out of the box, which let you let you focus on the actual stuff that matters, which is right in the actual application called large for your application, and you don't have to reinvent the wheel, and you can use many off the application that does many off the It was a really that does something we have.

  • No, I need to write yourself now.

  • Symphony is a friend, but what should I use?

  • Simple Symphony is a pastry from over that is made in my intend by sensitive loves.

  • It's been around for more than a decade, and it's been used by many large organizations, organizations and companies, and they still do to this date.

  • Now, why should you?

  • Symphony is up to you, but there are some things that I love about Symphony Now the first thing which is the most important thing for me, is the community that's the most lovable thing about open source in the symphony community is just extremely huge in full of airport people.

  • That will help not not just understand the concepts, but sometimes even a deal with your own applications knew about your own code.

  • Symphony has a slug workspace where you conjoined and ask other ask or answer questions.

  • Theo Course Symphony developers could be found sometimes hanging around there in case you wanted to ask him something specific about the framework or even discussed some some patterns or some code.

  • But the community itself is extremely up for a second man, which is the thing that I care the most about.

  • Open source is no longer maintain and abandoned packages I hit when I start using some tools or framework and the purple just decide to move on with their lives and ask no one to take care of that or maintain that package anymore.

  • But not that that's not the case with symphony.

  • It's maintained extensively and gets up to updated frequently.

  • And you could even have have a glimpse or what's coming.

  • They're coming out by going through some of the bull requests.

  • Get up.

  • We don't know what get up is horrible.

  • Request is, that's another symphony thing.

  • You don't have to worry about that.

  • The third thing that I love about, which is something specifically symphony for it, that some people used to say that before symphony was used for large applications and not you could match use it for, like small applications or even medium obligation.

  • That's not the case anymore.

  • Thanks, System 24 which is just a small framework, like like a parent.

  • So you know you don't have bundles or modules or whatever big frame was called them, but you can have them if you want to.

  • But symphony for comes a za mini frangible so you can install it.

  • It's it works for small to medium size frame ups, and you can even make it for lord applications and even even large applications.

  • Now, let me just point you to the slack.

  • I think that I was talking about this is this leg.

  • If you go through the same thing about gone, if you get on this black icon bottom, you're gonna you're gonna be taken to the symphony space on the slag, and you can just join creator account, joined them anything, ask questions or answer questions or whatever you want to do your job now, enough chitchat.

  • Let's get to some six minutes stuff.

  • Now, the first thing before we get started, we're gonna need some stuff we gonna need.

  • So in order to use a whip application, we need a couple of stuff.

  • So symphony is a PHP formal.

  • So obviously we're gonna need the HPD.

  • We're gonna need an impetuous a web server.

  • I'm gonna use a bachelor like you can use engine X.

  • If you wantto we're gonna need a database system.

  • We're going to use my sequel in this case.

  • And we get a need composer, which is just something to help us in small packages, even on star symphonies.

  • This in itself.

  • And we get in a a text editor or I d I'm gonna use PHP Stone because that's my favorite.

  • So let's go ahead and get started with installing some stuff.

  • The basic then, which is BHP in a Web server in database.

  • Could be unspoiled at once by using ma'am stock.

  • Just go to proving days.

  • I'm gonna go to Google.

  • I'm gonna I'm gonna get now I'm using a bond to you So I'm gonna down the day Correct version for me.

  • So this here's what I installed.

  • I asked all this big night middle car I'm gonna click back there and right away it's gonna take me to the space right to you.

  • I didn't see Windows Magnetics is gonna come on this space and I'm just gonna click download for Lim 64 bits and bytes on gonna know banks 64 bites And I'm going to say the fight it's going down that you can see I already down in the basement exploded days just to save some time.

  • Now, after you, you download that.

  • What you want to do is it's not gonna work.

  • It's just double click on it.

  • So what you have to do is you have to open a terminal terminal.

  • It could be fun.

  • I'm using a bunch of 18 so I can either play on this eye on writing a show applications and just start typing type here.

  • And as you can see, I have three Germans and start.

  • I have the regular terminal, which comes in with a banjo.

  • I have telex, which which is my favorite.

  • That's what I use.

  • And I have extent.

  • So I'm gonna use telex, which is why I usually use I'm gonna pick on that and I'm using the fish bash just in case I don't get the same thing.

  • I have something different, but everything should be to say the first thing you're gonna notice is we installed that.

  • So let's open our bras for the brother and I'm gonna git toe downloads.

  • And that's what I have.

  • My fine as you can see right here.

  • This is a five star there that I just don't know which I want to install that what you want to do is you want to change directory to bat for two.

  • That's forever.

  • But what we're gonna do is if you if you type PWG, it's gonna give you the current directory that you are, and this is harm.

  • And this is my user name.

  • If I take a list is gonna give me a list of all the all the folders that I have or in the funds that I had in this directory, and you got to notice that I have the downloads folder, which is what I'm trying to get.

  • So what we're gonna do is we're going to see the Don't knows just like that.

  • And now I'm inside the downloads for the fights like this.

  • You're going to see that I'm gonna get my father, Which is this one right here Now?

  • Usually it's not gonna be ingredient.

  • I ran a command previously for before we called in the video, so I'm not gonna get the same color.

  • It's not.

  • What you have to do is like smart plastics and the name off that round.

  • About five, actually.

  • Technically, you're not gonna get anything about where?

  • Whenever.

  • But if you talk this again, this should be green like this.

  • You should get the same result.

  • To run this, you have to type God's Slash and the name off that Manning lamps like.

  • Now it's just like the 1st 2 or three letters.

  • And I hit Tab.

  • It's gonna complete this for you and just, you know, move on with your life and just hit enter.

  • A few seconds later, you're going to see this set of window.

  • You just have to play next and you can check some of this stuff that you don't need.

  • Like, I'm just gonna leave something like that.

  • I don't even know what that that's what I'm gonna do next and by the forts.

  • And I got it installed for me.

  • It's gonna give me an error, but I'm gonna do next.

  • As you can see, it's going to say the father is not empty.

  • This is not gonna be the case for you if you don't have this installed.

  • So what you're gonna get next is just to imports asking for the password to the database.

  • I just entered six zeros, and this is just clicked and stop, and it's gonna install on.

  • That's it.

  • You don't have to go.

  • And after you're done, you are done installing this.

  • You're gonna get something like this window right here, which is the the manager for your for your hamster.

  • You gonna see we have three options.

  • We have goto application.

  • I'm gonna get that and it's gonna open this fuller at this 100 smoking host 88.

  • Now, you're not gonna get the same thing as me.

  • You're going to get ah, welcome message from the big NAMI application.

  • And that's that's not the case for me because I removed all the fun that unfolds that I have right dead just so I can, you know, move on faster and all that.

  • So you gotta get a weapon message And that is going to get from that beat Web server is what if you don't get that, then you have something wrong and a witch.

  • The second thing that you're going to see is we have open page beam.

  • I admit now be actually in my admin is what we used to manage Our database, as you can see it right away is gonna ask me.

  • It's gonna agree to use your weapon weapon to be my own man.

  • And you're gonna see we have a user name and password.

  • The username is just gonna be route by default.

  • Password is whatever you entered when you were installing the application, The two inputs that we just, you know, filled way were installing the Ramstein by defense.

  • I turned six years, so that's what I'm gonna do right now.

  • I'm gonna I'll be junkie.

  • As you can see, I'm in the dashboard.

  • I have my databases right here.

  • You can see I just installed this.

  • I don't have any other databases right away.

  • So we're gonna create our own when we get to that part.

  • Now, the last thing.

  • So let me just see what else we got here.

  • We have open application polo.

  • When you click this, you're gonna go to the lamps there directory where it's installed by default.

  • It's installed in the home directory for me, and you're going to see that we have a bunch of others that we don't need to worry about.

  • Now, the main thing that I want to point out is inside the Apache toe HD dogs this away.

  • Your applications will be will be now by default.

  • When you open this folder, you're going to see a bunch of fights.

  • Those are the funds that I was talking about when you open up when you played up goto application, you're gonna get a grating message.

  • That great message is loaded from this place that I just showed you like here, So I just didn't want everything.

  • And we're gonna get started right away.

  • Actually, we are not going to start right away.

  • We need to do we still need to install some spot now we need to start BHP this year.

  • Live for now.

  • We installed BHP when?

  • When we installed the lamps there.

  • Now this is great, and it's gonna run PHP and everything, but we need HP to be accessed from the command line.

  • And MEDLINE is just to be, except for me, because we're gonna use determinant to install some stuff.

  • And as I said, we're gonna use Composer Now, what are we gonna do with that money?

  • Time, Winston?

  • A chitchat.

  • Let's go ahead and search for something.

  • So I'm just gonna close this this one window and I'm gonna go to Google and I'm just gonna tell you, O bon Dieu Stark.

  • Uh, h he was going to be 7.2.

  • Okay, so let's go on.

  • Just just take whatever you find.

  • So So this is going to install about you?

  • We don't have to worry about that because we did that already.

  • Unless we want to.

  • You want to accident about you from the command line again?

  • That stuff.

  • Now, what I'm interested in is this spot right here.

  • So I'm starting BHP 7.2.

  • Now what you have to do is just take these commands and install them.

  • As you can see, it is going to instruct the HB seven point Joanna's going toe on slightly command line interface and is going to install some spot.

  • We bet after that what I want to do is I want to install some commonly used BHP extensions, and those extensions are used by composer and bite.

  • Actually bite the symphony in smaller and a lot of stuff.

  • Other stuff.

  • So what we have to do is just inspired those.

  • Now what?

  • I'm gonna do this.

  • I'm just gonna take this.

  • I'm gonna coffee this and I'm gonna go back to my tournament.

  • up.

  • I'm gonna hit shift concert to baste because there's no there's no control v.

  • I'm gonna enter, and I'm gonna answer my best work.

  • I'm gonna hit enter.

  • And as you can see, it's gonna do some stuff.

  • It's gonna start some stuff for me.

  • So I'm just gonna do a while, which is Yes, I'm gonna enter.

  • And if you get a dialogue like this just entered and it's gonna continue working and as you can see, it is done now, let's go ahead and try something.

  • If you don't be h speak like this.

  • If you want to make sure that GHB is installed, you can do GHB and it's gonna give you the version of PHP that is installed, which is 7.2170 now that is great.

  • Let's go ahead and do the second most important thing, which is this one?

  • Now?

  • It's not the most important thing, but it's important.

  • So let's go ahead and tell me this one.

  • Can that space that right below that I'm gonna enter.

  • And as you can see, nothing was been starting.

  • It was upgraded because I already installed baby.

  • So I didn't say I have everything right to you, but you're gonna get it's gonna install it for you gonna get some messages like it's like getting some stuff and all that, But it's gonna work for you the same way.

  • Now we have that stuff.

  • Now what we have to do to do next is been start composer.

  • Now, usually what I do is just go to school and I'm gonna do it in Stop compose once, and I'm just gonna choose whatever link.

  • So I'm gonna choose the 1st 1 because I know it's it works that way because I already did this, like, many times ago.

  • Just And as you can see, you can read through that if you want to.

  • About what I'm gonna do is I'm just gonna go ahead and install some stuff.

  • Now.

  • The first thing you want to do is you want to update your packages now.

  • We already did bad before we start HP obviously right here.

  • But you can just go ahead and do it again.

  • It's not gonna hurt anyone Next.

  • What you have to do is you have to install the current utility call.

  • Utility is what we're gonna use to gets the actual fight the Actually, it's Father.

  • I didn't seem right to you.

  • The next thing, which is the no, I already had that.

  • I'm not gonna write this, but if you want to, you just it's not gonna do it.

  • In my case, just gonna tell me that it's already installed.

  • But you can just go ahead and start if you don't have that.

  • Now, the next thing which is the most important thing is to download this.

  • Now we're gonna coffee this command.

  • We're gonna baste it in the last thing, which is the most important thing we have to do is we have to copy this command, which is gonna make composer to spread globally for us from anywhere on our assistance.

  • So we're gonna just can't be that command we're gonna it we're gonna base if we're gonna have to eternity and it did something.

  • So if you go ahead and try to get clearance Queen Blow didn't do a composer you're gonna see we're gonna get a bunch of commands.

  • Which means composer, it's one slug and work.

  • Now we are almost done with everything right to you.

  • I think we can move on.

  • I think we can go ahead and sponsor for me right now.

  • Now, symphony has two virgins, So you gonna you gonna see that we have the website skeleton version.

  • So let's just go ahead on and let's go to our dogs ht dogs.

  • And that's open determinant right here.

  • Now you can go to things you can either.

  • Go ahead, go to return it right to your insurance.

  • That directory using the command by or you can just go to your father.

  • I mean this this is specific to then it's you can right click and open in terminal, and it's gonna open the terminal with directory.

  • That's great for us.

  • So what we need to do next is we need to install symphony, so symphony is pretty easy.

  • Don't start.

  • We're gonna use Composer, obviously.

  • So what we're gonna do is we're gonna do composer create project, and I just think it's so creative.

  • Project I didn't see I only dance contest in the mother too, and start.

  • So as I said, we have to avenge the first important want this symphony that is not going to change.

  • So we gotta do symphony.

  • You can either Unspoiled websites skeleton like this or you can just consult skeleton like this.

  • Now, the main difference between those is that websites curtain will onslaught everything that you're gonna need.

  • The view's template in the, you know, the template engine that doc, chancellor of the mutation.

  • Everything that is related to simply to make an application work, its gonna be installed by default.

  • If you use just a skeleton and start, are you gonna get the core functionality off symphony and anything else?

  • Humanity.

  • You would have to stop that.

  • Now, this is the fourth course for Symphony.

  • So what we're gonna do is we're gonna install the court functionality of Symphony and we're gonna start moving up from there.

  • So I'm just gonna call this, of course, which is symphony course, and I'm gonna hit Enter now, this is the name off the full that is going to be created in my HT dogs.

  • Now, H detox, as I said, is the place where all the application on my Web applications lives.

  • So I'm gonna enter, and as you can see, it's done and we have most of the core functionality that we're gonna need me at.

  • Something reflects the character container and all that stuff that could stop me.

  • Now, as you're gonna see right here at the bottom, it says two things on your application.

  • You can either go, you know, Critical.

  • So actually, it's not what I was expecting.

  • Oh, this one.

  • So, as you can see, you can run a Web server without even installed an Apache or stuff.

  • You're gonna obviously need GHB in a database manager.

  • But you don't need a battery.

  • Actually, you can just run the built incident, sir.

  • Very that comes with simply now that that's actual server does not compute it in.

  • When you start the skeleton, you have to Scarlett.

  • Now this is a good chance to introduce Symphony Flex.

  • Now, Symphony flex is just a plug in for sympathy.

  • That helps you and start your plug ins and your components in your application.

  • The way that works is that its use something called a recipe.

  • If you go to descend to the website called Flex about symphony symphony dot com, you can see all the recipes that already exists in the, you know, on the server you can stop anyone beings that you that you want, you can see we have two types.

  • We have the country country, which is the contributions but community.

  • And we have the official ones, which are from the symphony.

  • A lot of sense.

  • As you can see, we have plenty off back.

  • Just write to you, and you can go ahead and filter those, like searching for the recipes we can track server.

  • And as you can see, we're going to get the whips of Blunt.

  • But so, as I said, you can run each application separately, and I probably that's what I'm gonna do, because I don't want to set up a fare to one host and let me explain to you what a virtual host it's.

  • So we just installed our obligation, as you can see it right here.

  • So everything is done.

  • So what I'm gonna do is I'm gonna try to see that it's running.

  • So what I'm gonna do is I'm gonna go to local host 80 80 which is where my server is running.

  • I'm gonna enter.

  • As you can see, I'm gonna get this father, which is, of course, which is the project.

  • But I just created by Click on that I'm gonna get a bunch of folders Now, this is a good chance to introduce you to start talking about the agitator structure off the four layers of symphony.

  • I'm gonna start about talking about the most important ones, which are the the SRC folder in the vehicle.

  • Now we need one more file folder, which is templates, but that's for the view stuff that we just couldn't stop.

  • That's for the future that we're gonna get after we install Twig.

  • Now this is a good Chester start, actually talking about MPC, which is what symphony uses and symphony, is based on N V C, which stands for for mother View controller.

  • Now NBC is just on our detector that separates your application into three separate spots.

  • The M stands for model, which is the model, is related.

  • Is everything related to your business logic or your actual code or their base entities or depository?

  • The V stands for view, and it's everything related to what the user way See, in simple words, you can say that it stands for everything related to HT, my related.

  • So that's it.

  • Anything HTML related will be the view.

  • The C stands for the controller in the control as we will see in second is what helps orchestrate between the model and the view section.

  • It's what we will use to indirect with the database on sense and data to review and hand the forms and much more.

  • So that's NBC.

  • Now, the view in this case is the templates that we don't have.

  • But we're gonna get that in a second.

  • The S R.

  • C is where we're gonna do most of our work.

  • So it's our CEO.

  • Will we get away?

  • Is where we're gonna have open shoulder.

  • Where we're gonna have our service is we're gonna talk about service is in a when we get to those is where we have our entities and where we have our own logic.

  • So I want to create some, you know, some code.

  • We're gonna put it in the car seat.

  • The folder that I want to talk about is leaking fix.

  • So convict is where all the configuration that we're gonna have, we'll be living inside this father.

  • So as you can see this work start up th you don't have to worry about that bundles air where we want to add some bundles.

  • Now this you want to have to actually touch or modify this file manually.

  • It's gonna be done by symphony Flex.

  • Whenever you install a new bundle or something that you get in, it is gonna be added automatically by Symphony Flex to this file.

  • Right here.

  • We have packages packages we're gonna have.

  • So you don't.

  • I know this is gonna be overwhelming for you the amount of information that I'm growing on you right now, but just to keep things simple, The convict folder is where we're gonna do most off configuration between need to figure anything.

  • The SRC folder is where we're gonna write most code the templates, aware our views and HTML files are gonna be living.

  • We have one more for the witches, the public father.

  • Now, this is the main entry to our application.

  • So if we click if you click on the public folder and you see this, then right here this window.

  • But I'm seeing right now, it means everything is working and you are ready to go and start symphony.

  • If you don't get this and you'll get some some other error, which means that you have got something around anything.

  • Probably checking installation on who gets some stuff with, You know, if you get some error that you don't understand now we have always symphony application, working and running.

  • Now, this is not working on the public just like this.

  • So So what we're gonna do is we're gonna go ahead and create our first controller, and we're gonna try to create a route out on route and see how that is going to work.

  • So what I'm gonna do right now is I'm gonna open up this father.

  • This has, of course, for that that we just created.

  • I'm gonna try to open up this with my editor, and we will continue from that.

  • All right, so I just opened the project with my favorite.

  • I'm gonna use BHP starts.

  • It's gonna help me a lot, especially if you're just getting started.

  • It's gonna be a lot of to use PHP strong on an i e.

  • I actually don't recommend views in just a text editor or something that does not provide provide any help or any until sense, But that's up to you.

  • So you can just just for your information.

  • So this is the age based on, and I was going to see inside our controller.

  • So we are trying to quit on you.

  • Control, we have nothing.

  • Now, this is where we're going to start talking about the consul.

  • So in Symphony, we have a council that we can use and one use to Joe crea generate some code that we don't want to write ourselves.

  • So I wanna write a control of what you have to do is you have to create five manually.

  • You're gonna have to get something like the main but domain controller, the h speak I'm gonna enter.

  • I'm gonna have to do speed.

  • I'm gonna try to give it a name space gonna be up controller and I'm gonna give it.

  • So obviously is gonna be a plus in the class name is gonna be remain main controller.

  • And this class needs to extends the abstract controller just And this is the beauty off.

  • Using an idea.

  • As you can see, I'm gonna do obstruct control and I'm gonna get into this instance and have so I'm gonna enter and it's gonna import the name space for me at the bottom of the sea.

  • It's gonna use that and I can just go ahead and start writing some stuff.

  • So this is how you can create to control.

  • As you can see, you have to write all this stuff if you don't have an I d.

  • If you're not using something that's gonna that has an Internet sensation, it's can do automatic important for you.

  • Now, using the council, you can just like one line and you're gonna be done with this I'm gonna do about this.

  • I'm gonna delete if, despite that I just created and I'm gonna go back to the terminal.

  • So inside my terminal, Aiken D'oh!

  • So first, then I am still in the route where all my projects live.

  • What I have to do is, I do, unless I'm going to see us.

  • Of course.

  • Now this is not supposed to be here About that, of course, is out for the way we are working.

  • What I gotta do is I get a good CD, which means change directory, a safe course.

  • I'm gonna hit enter and I am now inside that So let's clear the screen.

  • And to be able to access the council, what you have to do is you have to do PHP been stash process.

  • Now been slashed.

  • Ben is just the folder.

  • And counsel is the binary that lives inside the bent for So if you go GHB been slashed, Counsel, you gonna run this spinal re that we have right here?

  • If you enter, you're going to see a bunch of command.

  • Now, these commands are from the council are specific to symphony.

  • As you can see, we are.

  • These are the available commands we have about hell.

  • Placed assets, cash big.

  • The about lands.

  • Front of these are the basic stuff that comes with simple needs.

  • Skeleton the minimal version.

  • Now I want to make a controller.

  • So I'm gonna do that.

  • I need a command I'll make now make by default is not included right here.

  • So what you have to do is we have to go back to our symphony, a recipe servant, and we're gonna search for make.

  • As you can see, we have the as you can see, we have the makeup on right here, and it has these aliases generator may make a make a bundle.

  • Now you can use any one of these for writing in tow and slowly.

  • So what I'm gonna do is I'm gonna go back to my turn.

  • Look, and I'm gonna do composer required.

  • Now this composer required is it's gonna use Symphony Flex to install this for So what I'm gonna do is I'm just going to use the idiots make.

  • I'm just gonna copy that.

  • I'm gonna place it right here.

  • So composer require many quit and start the maker bundle for me was gonna use, uh, I'm gonna use to generate some controllers and others.

  • All right, As you can see, it is done.

  • And if we go ahead and run, the BHP been slashed.

  • Constant command again.

  • You're going to see that we're going to get a longer list right now, and we're going to see its make right here, which includes a bushel demands like make off.

  • We're gonna get to that in second in the second boat.

  • It's a bet.

  • Make command which which in create a command for you.

  • So this is a command, and you can even use them.

  • Make the man to make command a customized itself.

  • You can create in Charles, we get which is what we're gonna use.

  • You can make a crowd, you can make an entity, and we're gonna get into that later.

  • You could make it fixed a form, and you can see we have a bunch, a bunch of other stuff it's made.

  • Now let's get let's keep going with our example and we're gonna make a control.

  • So it's cruel to make control, and we're gonna get a college main control just like the one used before.

  • So I haven't got a tension I'm gonna get to, ever.

  • And as you can see, this is the beauty of Symphony Flex.

  • So the error is self explanatory.

  • It needs something to work.

  • This thing that needs is a plantation.

  • So what I'm gonna do is I'm gonna explain what?

  • What annotations are in second.

  • So what I'm gonna do is I'm gonna copy those annotations, and I'm gonna do so.

  • I'm gonna copy composer required annotations, and we're just gonna shift, insert and return keep, and it's going to inspire the intention.

  • Spooky.

  • All right, As you can see, it's done.

  • Now, what we're gonna do is we're gonna rerun recommend, so we're gonna I'm gonna hit the car to go through the history of my mats.

  • I'm gonna hit again.

  • And as you can see, I'm gonna get my command and to make a controller.

  • And I'm gonna agree, John.

  • And as you can see, it says success or Green means success.

  • It says that it created inside the SRC folder inside the controller for the experience something called the Main Control HP.

  • Let's go and see if that is true.

  • So I'm gonna go back to my idea, which is PHP scar.

  • And indeed, we have a fight.

  • We have the main control.

  • Now let's go ahead and open that fight up.

  • And as you can see, we have something similar to what we had before now things that we don't have this route and we have this index function right years.

  • Now, this is what's called an annotation.

  • Now, inside Symphony, you have three ways to configure your stuff.

  • You can either use annotations like this, which which looks similar to a comment and you have inside you can think we have examples off the yamma file.

  • For example, the salmon is just another way to say this right here.

  • So this is an annotation that says that this route So this is a road we're gonna start talking about rods in a second it says slash main.

  • And this is the name off the road.

  • Now, you can do the same thing if you don't want to do this.

  • If you don't want to use annotations, Euronext fan over.

  • You can get rid of this and you can use this Wrote about him.

  • Now, this is the same thing.

  • This is the name off the route that we have.

  • Something just grabbed lectures, Counsel.

  • So this is the name.

  • So we have made.

  • If we want to make the same thing, we're gonna change.

  • This elects to Maine right here.

  • So that's the name off the route.

  • Now, this is the Beth.

  • This is what we have, right?

  • You see, its patch may weaken, Do some black slash right here, And the controller is going to pour into which action to use this case.

  • It should be it's the index.

  • So if you want I want to use something like this.

  • We're gonna have to change this from language from the fort controls to mate, Controller and Index, which is going to go into that punch.

  • Now I'm gonna keep using.

  • And now I'm gonna keep using annotations.

  • I'm not gonna use the animal.

  • But just so that you know it exists and you used to want Now how do we actually so this as I said this around So if I go out to my my browser and do slash Main is going to get me this like here, As you can see for now, this is returning a Jason that says one comes your new controller and this is the path where so this is just some data you can have whatever you want to waken go ahead and change.

  • Welcome.

  • So, as you can see, I just changed.

  • Now if I go back to my browser and extracted in that So, uh, this is my obligation, that's what my running.

  • So if I do slash make which should take me to there is gonna give me an error.

  • Let's concede it says that it it's not fun.

  • That's because by default, when you do slash public, it's looking for the index to gauge P five.

  • Now, if I do that and I enter, I'm gonna get the same work, a message as well.

  • So what I have to do is I have everything that I need to add to my route needs to be after this.

  • So I had to do it remain like this.

  • And as you can see, I get welcome.

  • Three guards camp right here.

  • Which means our controller, it's working our way around this set up and everything is ready to work.

  • Now, as you're gonna notice, this is ugly as hell.

  • So nobody likes to use all this stuff right here.

  • Now, to fix this, you have to set up a virtual house.

  • Now, I'm not gonna do that.

  • I feel like this outside the scope of symphony.

  • It's not a symphony.

  • Specific thing is kind of It was a Web server thing.

  • So just so that you know, you can do that.

  • And you can set up a virtual host that would take all this stuff away.

  • So you can have really you around, like, for example, of course, slash May.

  • So this looks like an actual You're actually you're not this junk.

  • We have light.

  • So you could do that for you.

  • If you are using the built in symphony server, you can actually just do local host 80 the port where you can even run the name you can give it like since.

  • It's of course, that there just the way we did a second ago and you could do slash May.

  • Now, Asai said, I feel like that's outside the scope of the symphony.

  • Of course.

  • So what I'm gonna do is I'm just gonna keep it this way, or we can just go ahead and use the beds and second, sir.

  • Now this that's better.

  • This does not bother me.

  • So I'm just making space now.

  • We just created our first route.

  • We're going to take me to So this is the first route.

  • Let's say that we want to create our hardworking.

  • That's so well, if I get rid of May, but you can see we're going to still get this page right here.

  • Let's say that we want to create our own custom message on our car on home page.

  • If you want to say so.

  • What I'm gonna do is I'm gonna change this from Maine to just slash which means the heart.

  • So this is the road root directory.

  • You want to call it that went off.

  • I'm gonna change the name off that rug to home, and I'm gonna give the function index and I'm gonna keep the same.

  • It's actually, you know, I'm gonna get I'm gonna get rid of that and I'm gonna reach up on you.

  • Now, what's a response?

  • A response is something that every action inside simply needs to reach.

  • I'm talking about the actions, not every single function, but this is an action.

  • So each action within a controller needs to return a response.

  • And that response lives inside symphony components.

  • Http foundation so don't get this messed up.

  • A lot of people import the wrong name space, and they just spent three days trying to be about something that is very simple.

  • Always very intention to the name space that you are important in this case, we need http foundation.

  • So we're gonna hit enter.

  • As you can see, I'm using GHB storms.

  • It was going to import that automatically for me, and you can just do sitting on it again.

  • Now this is empty.

  • So if I go ahead and try to refresh this as you can see, I'm gonna get an empty page because I did not add anything to this response.

  • Now, what I'm gonna do is I'm gonna just by the strength that tastes um html So I'm just going to do something like h one h one.

  • I'm gonna just do weapon and you and I'm just gonna go ahead and refresh my face.

  • And as you can see, I get my message.

  • Welcome free called Camp.

  • Which means this is what So our index has changed from just, uh, you know, that regular symphony work message to this custom country controller action that we just made.

  • So we just made our first from now let's go ahead and try to create another function.

  • So another action with another round just to get familiar.

  • So what we're gonna do is just below this, we're going to create another action.

  • So let's go public function, and you can call it what?

  • Everything you want.

  • In this case, I'm just gonna call it trusting.

  • Just gonna be like that Now, this is just a function.

  • So if I just try to do something with it, it's not gonna work.

  • Now what I need to do is I need, as I said before, to set up a road for it's because I want this to be excellent from the rug.

  • So what I'm gonna do is I'm just going to do.

  • I'm just gonna copy the Sandbrook.

  • I'm gonna base it right to you.

  • And I'm gonna change this from just slash because we have to.

  • So I'm gonna change that form slashed to slash custom.

  • Let's say that that's where we want to do in this action called custom.

  • Now I'm gonna change the name.

  • So I'm gonna change that to customs.

  • Well, we need to return something, so if I just leave it like this empty.

  • And I tried to go to that, you're out.

  • As you can see, I'm going to get an error.

  • The controlling does not return, Mr Responsible.

  • Except the controllers must return something that it stands.

  • This response it's must return response.

  • Now, let's go ahead and return a response.

  • So we just kind of return your response, and I'm just going to do something like, uh, yeah, that's got to be the same thing I would like to hear.

  • And it's called Let's just give it something like All right.

  • So I that set up, I'm gonna go ahead and refreshing space.

  • And as you can see, I'm gonna get my message.

  • Customer base.

  • So that's it?

  • We created.

  • Thio recreated the controller.

  • We've created two routes and we've been accident them both.

  • Now let's do something that's let's go ahead and talk some more about proud.

  • Now we're gonna get to those in a second.

  • We're gonna start.

  • We're gonna explore the further more, But I want to do something.

  • Let's say that we want to create a page.

  • This is welcome to some user name, but we're gonna enter.

  • We're not going to use a form or something.

  • We're just gonna use You are a Now we got a chance.

  • Our custom function that we just created right here to do that's for you to do that for us.

  • So what we're gonna do is we're gonna change the u R.

  • O.

  • Now.

  • As I said, we want to be able to do something like slash user name.

  • I'm gonna do like, free.

  • So I'm just gonna go free like that camp when I hit Enter and you're gonna see is going to say that this rug this night exist.

  • That's because we have not yet.

  • So that's where we're gonna try to do now.

  • How do we get it to take that?

  • Something that is going to be dynamically right here.

  • We gotta go back to our rug to our customs Slash.

  • And what we have to do is we have to set up some abruptly that is going to be dynamically changed and have to do that.

  • We're gonna use the curly braces like this, and we're gonna give it whatever name one.

  • So let's say hello.

  • Name.

  • So this name right here is going to be accidents, so we're gonna access that, and that is going to be the name that we're gonna greet.

  • So instead of work days, we're going to say what?

  • So that's user name.

  • And how do we get access to that username right here?

  • So that's what we're going to see right now.

  • Now, Inside each action, we have access to something called the Request.

  • Now, the request is where all our s O.

  • Basically is a request that comes from the client and includes a lot of stuff like that.

  • It sent the queers that he sent.

  • It was his are just like being on a bunch, probably his time zone and a bunch of other other use now to get access to that request.

  • What you have to do is within the parameters that you have foreign function or your action.

  • We can just use equals.

  • Now again, you need to pay attention to the name space.

  • You don't want to import the wrong names Place for the request.

  • You want to import the http foundation one Don't do the browser kid stuff.

  • Whatever Just do ht important the http foundation name space pay attention to that is going to save you a lot of time and it's gonna avoid some head aids.

  • So frequents.

  • Let's give that a name.

  • So you have a request like that and we got access to that.

  • Now I'm gonna bait productions to get rid of that line.

  • And next we can go ahead.

  • So how do we take a look at the request?

  • How do we know what request contains?

  • Now we've been symphony.

  • We have a function called dumb.

  • Now we use them too.

  • It's similar to borrow a dump, but it's actually better.

  • It's s so I'm just gonna show you how it looks back in a second so you can use dump to dump the request.

  • So let's go ahead and do that.

  • We're gonna dump the request, and we're gonna see what the request tanked.

  • Now, if I go ahead and just refresh this fish, it's not going to work as a C.

  • It's gonna tell me that this custom does not exist.

  • That's because this is obviously so I need to enter the name.

  • I need this name to be to exist.

  • I want this to be optional, so a CZ you can see we don't have it right now.

  • What I can do it is, I can add this.

  • It's explanation Mark, which is going to make this optional meat.

  • So if I go ahead and just say this injury fixed bases can see even if I don't enter any user name is still going to work.

  • And as you can see with its working, we still have an error.

  • But it's a different era, but that he is working.

  • As you can see, we got custom without user name, and it's working now.

  • As you can see, the error is that we are trying to call a function that does not exist this dumb function now to use that we have to go back to our simple recipe server.

  • As I said, while using the minimal version which does not include anything.

  • And we have to go and look for done.

  • So I'm gonna type thumb, and as you can see, we're gonna get the symphony of our dumper.

  • So what we have to do is we have to unspoiled that.

  • Let's go back to our terminal.

  • Let's do composer required.

  • And I'm gonna use this alias right here, which is dumb, and it's just group Come, as you can see, it's done.

  • And if we go ahead and try to actually, before I refresh the baseball, actually, let's just go ahead and refresh this.

  • As you can see, this is what the request looks like.

  • Now the dump is nicer because that's conceived unfold.

  • You don't have all the information like going to have a 1,000,000 lines that you have got to scrub you.

  • You got all the basic stuff that you're gonna need requests.

  • So this is what the repressed dance, and you can go ahead and fold and unfold whatever you want.

  • As you can see, we have the server and we have all the everything that we possibly me.

  • Now Where were we just doing that one thing that I food that I didn't do in the beginning.

  • And I feel like somebody is probably gonna be asking about this.

  • I want to use the built in symphony just so let's say somebody don't want and stop all this stuff.

  • So what I'm gonna do is I'm gonna use the built in symphony and I'm gonna show you how to use that and even to get rid of all this nasty stuff that we have to.

  • So I'm gonna go back to Symphony A recipe server, and I'm gonna look for certain.

  • Now, this is the Web server that I'm looking for.

  • So what I'm gonna do is I'm gonna go back to my terminal.

  • I'm gonna composer require it directly, and I'm gonna Observer.

  • As you can see, it is done downloading and installing the server.

  • I don't have to do anything else stand thanks to simply flex.

  • Now all I have to do is run the server.

  • So how do I run that, sir, that what I'm gonna do is we have to.

  • So actually, you can just go ahead and let's do Cage people Counsel.

  • So we're gonna run this from a command.

  • So if I do PHP been slashed constantly gonna see that we have a new set off new stuff meant which belonged to the server name space.

  • It's the 1st 1 server run which we're gonna use.

  • And there's also server start, which starts which do does the same thing a several run.

  • But it does that in the background.

  • So I'm gonna show you the difference in second.

  • Actually, let's do it right now.

  • So if I do gauge been slashed Council server run.

  • As you can see, it's gonna take this German and it's gonna keep using it.

  • It's gonna post whatever requests that I make like to you.

  • So this is where my application is living a zat gun show you right now, If I go back to as you can see 1 27 0.0 dot one, it's just the it's just the others for local horse so fine type local host, it's gonna mean the same thing of the port is the most important thing.

  • It's 1000.

  • So let's go back to our Web browser and let's drink to that.

  • I'm gonna leave this open right here, and I'm gonna do with local host Now it says 80 80.

  • So I'm gonna change that to 8000 and I'm gonna enter.

  • And as you can see, I'm gonna get the same thing.

  • Welcome to be away from Freeport can.

  • Now you're not gonna get the same junk that you have right here, which is as, of course, public index dot PHP and then you get access to what you want, but you can just accident directly from he

Hello, everyone, and welcome to learn symphony for the four course for beginners.

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

A2 初級

Symfony PHP框架教程--全課程 (Symfony PHP Framework Tutorial - Full Course)

  • 0 0
    林宜悉 發佈於 2021 年 01 月 14 日
影片單字