Laravel Tutorial For Beginners | What Is Laravel? | Laravel Training Part - 1 | Edureka

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello all and welcome to this webinar on larvell in this session we shall be discussing the fundamental school concepts and pretty much all you need to build projects in larvae will also understand various concepts of prototyping databases and api along with some larval specific projects our attendees here are a well rounded representation of the globe we have mr. Neil row here who has years of valuable experience in this field and he shall be taking us through this module welcome name over to you hey so welcome to the first part of a new series this is the laravel series and it's effectively going to teach you pretty much everything you need to know to get started building products with laravel so if you never heard of laravel or you've kind of heard of it but don't really know what it does laravel is a framework and a framework is essentially the starting code to building your project so instead of you having to write out all of these functions and all of these methods and controllers and things the same code for all your projects laravel is like this starter kit it kind of includes almost everything you need so it makes a brilliant force or prototyping or building projects really quickly because it really has been built for so many years and they've really built up this whole platform where everything you could really need to build a start up or to build a web app is already included so I'm talking like database stuff so there's so much sort of stuff for relationships and handling those relationships it does it really neatly rather than having to write out your own queries and handle them yourself things like sockets if you want to use socket die o or pusher it's all built in there's tons of API stuff so if you want to take payments again there's kits for that they're all built in so you can use like stripe or Braintree or PayPal really nicely and on top of that there's a site called packages which is essentially a load of packages that you can include in your project these come through a piece of software called composer and these are packages built by other people other organizations which you can make use of and composer will keep these up to date and to freely handle it all for you so for example if you want to use the Facebook API you can literally just import a package which will give you a load of functions in PHP that you can access really nicely and if you've used composer before you'll be familiar with that but in laravel there's tons of laravel specific projects as well and you'll see those at some point in the course anyways laravel is a currently in version 5.7 at the time I'm recording this it doesn't change massively between versions so if you're watching this a year later on we're on 5.9 or something this should all still be very relevant this course is really going to teach like the fundamentals rather than anything actually specific it's going to teach you the fundamentals to get started and then go off and learn by yourself or by other means it's really going to teach you like this the core concepts of how laravel works and how to just get set up with it and those kind of things don't really change between versions so there should be a problem so to get started with laravel you're going to need a program called composer as I say composer is the package manager is the most common one for PHP if you're on a Mac or Linux or a UNIX system we got to do is copy and paste all of these lines into a terminal and it will install it all for you it's really easy and if you're on Windows there is actually an installer somewhere on here I think it's in getting started you'll see here yeah install the composer setup the exe and it will do it all for you it's very simple to get set up so I think most of you shouldn't have an issue once you've got composer it's really dead simple to install PHP what you got to do is jump over to your terminal so I'm using Visual Studio code which I'd highly recommend it's got a built in terminal so you've got a jump over to your terminal and type in composer to launch the composer program create - project and then the project is called laravel forward slash laravel and it's named this because that's the sort of github organization and then laravel was the project name and then after that you give it a name so I'm gonna give it social in this short course we're going to be going through like a Twitter start it will show all the fundamentals so we'll be doing database stuff I'll be showing your models controllers views maybe a little bit of JavaScript but this is not a JavaScript course so I wouldn't count on that this is purely a back-end course so of course it's going to show you how to get set up all the fundamentals and then from there you can go on and expand on this so I want to let that install it should just take a couple of minutes that's installed you will see they're actually set up an application key so this is like a unique hash it's base64 encoded for your project and that leads me into the dot env file now don't you envy if you're unfamiliar is effectively an environment file it really specifies the environment that this project is running so you'll see things like the app URL the app name the database credentials male drivers various stuff like that you can also put things at API keys in here if you want to store them and effectively if you've got two environments let's say you've got a staging environment for testing and you've got a production environment you can have different database details different app URLs different API keys blah blah blah and these dorian view files are not synced in gear so they're in the gate ignore file so if you put this repository on two servers they'll both have separate DMD files that's how we use it in my work that's how pretty much everyone does it so first things first is to get it set up with some settings the top ones don't really matter too much as long as you've got debug true for testing that will just show you all your error messages pretty much the DB connection you'll need to have that so you can add to have a my sequel instance I'm not going to show that in this video because it's pretty basic to get set up but you're going to need your login details in your port and blah blah blah so my database I've got it in a program called navigate you can also use sequel Pro my database is called there so I'm just gonna paste that in here my username is root and my password is also root this will vary depending on your my sequel setup if you're using like man poor lamp or built in my sequel or whatever I you just need to find out what your login details are and then that's it for the environment file that's our database setup so in order to test your project you can run a command in the command line called PHP artisan serve and that's literally going to start up laravel built in server and that failed because I need to change directory into the social folder because I'm currently in the laravel folder but I've also created a project inside of that so I'm going to CD into social and PHP artisan artisan serves again and there we go we've got laravel development server started and that is the link so I want to go over here and go to my local host and there you go there is the home page this is just what comes out of the box you'll see it's just some pretty basic HTML and some CSS going on in there okay if I actually go to any links you just get a 404 because nothing's actually built yet all right so the first thing I want to do is set up a login system now if you normally use PHP or some other language you'd have to first of all you got to create the table in your database and then you've got to think about what hashing method you want to use and then you've got to create the register form and then the login form then the forgot password form it's very tedious and if you've ever worked on multiple side projects you're probably used to building this exact same thing many times and this can take you a couple of hours to build so if you're doing that for lots of different side projects it's totally unnecessary laravel does this for you it thinks about security out of the box so you don't have to it's just an all-around nicer environment to use so to setup authentication what we're gonna do is PHP artisan migrate and migrations are basically schemas and it tell is the script to build a database so it's not my sequel it's a script telling it how to build the database tables and these are stored in database migrations and then the migration names are here they've got a timestamp and then a name so the first one here is create users table and you'll see it's got a public function up which is to create the table and the public function down is to reverse it to drop it so up will create a schema which is effectively the table the table name is users and then it's got all of these columns so it's gone ID which is incrementing and it's got a bunch of strings so password email name a remember token which you'll see in the database is effectively a token for if the user decides to remember themselves and time stamps these are created at and updated at and laravel handles those automatically so this migration comes up the box but you can make your own which I'll show you that this one is specifically for authentication so I'll hit my green so I go an error which looks like it's because yep my login is incorrect for my database so I'm gonna just go check on that now that's in the DNV far if you see anything like access denied for user check your database settings and it turns out the reason here why mine did not work is because my password is actually root but again that really varies based on however you set up your database so I'm gonna go ahead now and run PHP artisan migrate again and see if that does the trick there we go migration table create successfully so it creates a table that keeps track of the migrations and then it migrates these two tables so create user's table and create the password reset table so back in my database now I go ahead and refresh sure enough we've got three tables the user's table is the one that we want right now so we've got name email password remember created and updated at the benefit of doing this in your code rather than just making tables it might not make sense for just one person but when you've got a team of people the fact that they can just run PHP artisan migrate to get their development environment set up um is so helpful it means you can keep your database in your version control whether that's get or whatever it just makes a lot more sense you can also use things called seeders which can populate the table with dummy data so let's say you want to populate it with some dummy customers you can do that too and that can be really useful for getting other developers on board but I'm not gonna go into that in this because this is really just a getting started guide okay we're now ready to really get set up with our authentication so to do this PHP artisan make : auth and you can find all of this in the laravel documentation this command literally sets up all of the PHP functions the views the controller's it resets them all up to set up a whole login system this includes login and registration so if I run that authentication scaffolding generated successfully so as I say this comes out the box and then I need to run PHP PHP artisan serve to get my web server running again when i refresh you'll see login and register suddenly appear so we're going to go ahead and register so I'm going to register with some details I'm gonna go test at test com I'm gonna set it a password I'm going to forget password and password and you're now logged in so this is also by laravel as you can tell we're only like five ten minutes in and we've already got authentication we've got our database set up it's doing it all for us we've already got like some scaffolding so a logout button etc and we can log-in again using tests at test comm password and we're in it's also got some forgotten password scaffolding that's already done right out of the box so it's really neat it really saves you like many hours if you're someone like me who comes up with side projects and then ditches them very quickly this can be really useful because you can build things so quickly it's great for prototyping it's great for building projects quickly I use this where I work and it saves us so much time a couple more bits I want to round up in this video is the whole MVC architecture behind laravel and behind pretty much any framework nowadays MVC stands for model view controller and these are the three main things that make up an application so starting off with model models are effectively your data stores so in this case of my sequel database a model represents a table in the database and these models can be related to each other using relationships just like you would use in Lara in normal my sequel using a join query you can have multiple models that's a collection and then you would loop through a collection to retrieve individual models so that's really it so each model usually doesn't always but usually represents a table that's related to it model can also represent API lookups and all sorts of other things but I'm not going to get into that it's just too confusing a model generally represents a table with a similar name the next part is views now a view is literally pretty much as HTML so it's deals with the outputting of data on the screen or in emails so if you literally deals with outputting on the screen or emails and things like that so most of the time this is just HTML but peter laravel comes with something called blade blade is the templating engine and if I go on the documentation you can see some examples there so it's effectively HTML but you can insert these smart little snippet so you can have sections if you want to master page with the header and the footer and all your JavaScript and then you can have the content separate it means you've only got to ever edit one file if you've done a regular old PHP you probably included a master page but it gets really funny if you want to set titles and things like that laravel has really thought of everything so you can't go wrong you can also do things like if statements within the HTML loops so you can echo variables components came out and a few versions ago that's quite recent there's just so much stuff slotting components there's really tons of stuff and really for most people it's going to be perfect it saves you so much time if you've ever done regular PHP you might also have done string replaces where you import a HTML file using file get contents and then you string replace various tags within that file I know we used to do it where I work and it's a nightmare after a while so blade really kills it is all for you you might have also used something like smarty templates which are pretty good but blade is really awesome anyway the final bit is controllers and this is where the actual logic happens so this is where you might process data you might have to do calculations effectively your controller is what links your models to your views it really is what handles the logic and it goes and gets data from your model as it pushes data to your models and then it goes and outputs that view it's really like the middleman of your project and that's it for MVC really one final thing I want to talk about in this episode before we actually get started is roots so there's a file called web dot PHP by the way using a text editor like vs code is brilliant because of the search when you got laravel with so many files it's so handy but web dot PHP is in this folder called roots along with console channels and API so what this file is is it's effectively a list almost of URLs on your site so for example /home will take you so this controller the home controller and the function or the method inside of it is called index and then we also name that root so that we can retrieve it later this last part is optional you can also create a route like this so root colon colon and then the either gear or post so I'm gonna go to get and then you can have slash test and then you can put an inline function in here or anonymous function I think that's called where you go echo whatever so you don't actually have to reference a control on a function you can also put a function right inside there but generally for organizations sake you want to do it like this there's also tons of things like route groups middleware tons of other stuff to go with it through but that's going to be too much for this episode I'll quickly touch on middleware though middleware is like a middleman between the base layer of your project and actually getting to those controllers it's like a security guard standing at the door before your controllers and it checks you out and decides if you logged in and then lets you in or pushes your way so for example if you've got a page that only authenticated users can go to you might have a middleware that checks they're logged in and if they're not says kebaya and if they are logged in it lets them come through to the controller but yet I'm going to leave this video here thank you so much for watching and I hope to see you in the next one I hope you have enjoyed listening to this video please be kind enough to like it and you can comment any of your doubts and queries and we will reply them at the earliest do look out for more videos in our playlist and subscribe to any rekha channel to learn more happy learning
Info
Channel: edureka!
Views: 107,274
Rating: undefined out of 5
Keywords: yt:cc=on, Laravel Tutorial, Laravel Tutorial for beginners, laravel tutorial for beginners step by step, laravel project, laravel installation, laravel from scratch, laravel php framework tutorial, laravel framework, laravel 5 tutorial for beginners, laravel 5 tutorial, laravel api, laravel api tutorial, laravel project tutorial, laravel api authentication, laravel beginner tutorial, laravel basic tutorial, laravel cms, laravel database tutorial, laravel datatables, edureka
Id: bkyjiXSx6WE
Channel Id: undefined
Length: 17min 9sec (1029 seconds)
Published: Tue Sep 04 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.