Laravel From Scratch [Part 1] - Series Introduction

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey what's going on guys as promised we're finally going to get into laravel so I don't think I've ever had as many requests for a single video as I've had for this one and I do have some good news for you which is that this is going to be a series initially I wanted it to be a crash course but I quickly came to find out that to include all the parts of laravel that I wanted to cover it's not going to fit into an hour or even an hour and a half and that's longer than I normally like the crash courses to go plus I know a lot of you guys prefer the modular series format over the crash courses so we're not just going to be covering the fundamentals of laravel but we'll also be building a project start to finish so in this video we're going to take a look at what we'll be building and we're also going to talk a little bit about laravel and some some of the things that it can do so let's go ahead and get started this video is sponsored by dev Mountain if you're interested in learning web development iOS or UX design dev Mountain is a 12-week design and development boot camp intended to get you a full-time job in the industry to learn more visit dev mountain comm or click the link in the description below alright so before I get into what we'll be doing let's just talk a little bit about what laravel is so laravel is an open-source PHP framework and the creators of laravel have said many times that they aim to make the development process pleasing without sacrificing inequality so laravel is very elegant and things just kind of seem to to work together very nicely not only is laravel popular but it's also respected which is funny because there's a lot of programmers that look down on PHP and I've even had subscribers straight up tell me they hate PHP and it sucks and then later on ask me what I'm going to do the lateral course so it's almost like they don't know or don't care that it is PHP and I think the reason behind that is because laravel really goes against that unorganized spaghetti code stigma that PHP has all right laravel uses the MVC or Model View controller design pattern we'll be talking about that throughout this series but basically the model deals with the database the view is the user interface that displays in the browser and the controller handles requests which come from either URLs or forms get requests post requests deletes and so on and we'll be covering this stuff extensively throughout the series all right so I've come to learn that most of you don't like the ongoing series where I release a video once every week or two and honestly that method is kind of been a pain in the ass for me as well so we're going to do this all in one shot I'm going to finish the series and then I'll upload one video after another and it may it may span over a couple days but we're going to get through this series before I start something else so before we look at the project I just want to go over what what the series includes so I'm going to briefly go over the fundamentals and some slides and just give you a better understanding of what laravel can do before we get started and then in the next video we'll install composer which is a PHP dependency manager and we'll install laravel with that then we'll start on our application which will basically be a website with a blog system now I outline this application in a certain way and that's so that we can touch on all the main points that we need to and still create something from it so it'll be a full crud application create read update and delete will create routes controllers models will deal with database migrations and all of that all right then we'll implement authentication so that users can register and login we'll add access control we'll add all the foundation that goes into building an application all right we're even going to implement file uploading and things like pagination so I'm going to even try to deploy the app somewhere PHP is usually easier to deploy than something like nodejs or rails so that shouldn't be too bad all right so like I said this course will cover this series will cover all the fundamentals of laravel and get you started but if you're still hungry for more after that I would highly highly recommend getting the ten project core so that just created for our Onix what we talked about in this youtube series covers about the first three projects or so at least the same type of material but the course will go on to create seven more projects and I try to make each one different so for instance we'll deal with file uploading and storage with the photo gallery we will build a REST API with a front-end we'll use the October CMS in one project which is a production laravel app will work with the Twitter API we'll use view Jas and the contact manager will use postgrads in the bookmark manager so I try to make every project different so it's not the same thing one after another and if you do go on you do purchase the course please use the affiliate link in the description or go through traversing media I get a fixed price for these courses and then the only way that I profit after that is by affiliate links so I would HIGHLY appreciate that from you guys all right and I'm going to be creating my own udemy courses soon alright so now that we get that out of the way let's talk about what laravel actually does for us alright so why would we choose to build an application with laravel over just building it straight up from scratch there's actually too many reasons to list so I listed the important ones so laravel handles routes in an extremely simple way you can simply define what URL and what type of requests that you want to handle now most MVC PHP frameworks do this as well such as you know such as code ignitor or CakePHP but some of them some of the routing files are really difficult when dealing with expressions and dynamic URLs and things like that laravel makes everything very very simple which makes it a great candidate for restful api s laravel also adds a security layer to your app so it automatically escapes what it needs to it implements cross-site protection with forms and submitting to the database among other things working with the database is also incredibly easy laravel is shipped with an awesome command-line tool called artisan and lets us do pretty incredible things with just single command so one of those things is to create database migrations now if you've ever worked with Ruby on Rails or some of the other frameworks some pipes some of the Python frameworks then you know how helpful migrations are they let us do things like create and edit tables and columns and set constraints in the database and much more now with something like code ignitor we have to go in and manually do this stuff either with the console and SQL commands or something like PHP myadmin alright laravel also uses the blade template engine to display views we can extend layouts we can use control structures like loops and conditionals right in the HTML alright so there's also there's many different ways to implement authentication but laravel sets that up for us so it automatically creates migrations to create the user table and all we have to do is run a simple artisan command to enable everything okay to enable authentication laravel can handle sessions the latest version which is 5.4 that's the version we'll be using it uses laravel mix to compile assets if I believe 5.3 used elixir we can easily use SAS which is a CSS pre-compiled err that lets us use things like variables and mix-ins in our CSS alright so there's also a core storage library to to do all types of things with files to upload files and manage them transfer them and so on error handling is pretty easy to do messaging things like that unit testing although we won't be getting into that collateral does ship with the ability to run tests all right email configuration for smtp if you wanted to have like verification emails sent from your app things like that and laravel also handles cache pretty well so these are just some of the things that some of the benefits to using this framework so as far as the environment goes our development environment I'm going to be using Windows and we're going to use xampp which gives us an Apache server PHP and MySQL on our local machine everything we need to run laravel it's completely cross-platform if you have a Mac or you're using Linux you can use xampp or you can use something like lamp or MAMP man pipe believe is only for mac or you could just use the native lamp stack if you're using something like a bun - which is probably a better option if you're using Linux but installing the IR bill is also pretty easy we're going to use composer which is a dependency manager this is kind of like NPM if you're an ojs developer we're going to install that and then we're going to run this simple command to create a new laravel project all right now once we do we install laravel everything that's viewed in the browser is going to be put into the public folder and what we want to do is set up a virtual host with apache to point to that folder because we don't want to have to go and actually go to slash public it's also a huge security concern so you definitely want to create a virtual host and I'll show you exactly how to do that all right so I mentioned that laravel has it comes with artisan which is a command-line interface and it's incredibly helpful and easy to use some of the things that it can do I have listed here but there's a lot more it can create controllers and models so we don't have to go and actually create the files manually and add the class and so on it can create the database migration files and run those migration files it can create providers events jobs form requests etc it can show us the available routes in our application it can we can create session commands we can run tinker which is a nice little shell program to interact with the database so if we want to quickly insert something or select some rows or something like that tinker is a really nice tool for that you can also create your own custom commands ok so these are just some of the things you can do so here are some examples of artisan commands so what you would do is PHP artisan and then the command so list will actually show you all of the available commands that you have help if you want to do help and then a command it will tell it give you some information on that specific command make is a really helpful command that we we can make different things such as a controller so in this case we create a - duze controller we can create models with make model now models should be singular and controller should be plural alright now this - M right here what this is doing is it's telling it that we want to also create a migration for this model because we want to add some field had a table to the database okay and if you wanted to create a migration separately you could say make migration and give it some kind of descriptive name in this case add - duze - DB okay so there's no mistake what this is what this migration does and then if you want to run the migration file you can just do PHP artisan might migrate all right and then if you want to run tinker and you want to interact with the database PHP artisan tinker will do that all right so eloquent is another really great feature that laravel uses it's an ORM or an object relational mapper that uses active record and it makes working with models and working with the database very very easy okay and if for some reason you didn't want to use eloquent you don't have to you can just use the standard DB library and you can just create raw SQL queries but this is an example of how we can bring in a model and save a resource in this case it's it to do so use app to do is going to bring the model in then we just create a variable and we can set it to a new to do then we can add fields in this case we're adding a title of some to do and then we can just call a save function okay so this will do all the insert for us we don't have to write insert into and and all that stuff okay so it's very eloquent all right so as I said earlier laravel also uses the blade template engine which in my opinion is one of the easiest to use all right it's very very simple it's also very powerful we can use control structures like if statements conditionals loops and so on we can use PHP tags within the template we template inheritance is also really easy we can create views and then we can extend layouts what I mean by that is we'll have our main layout with the HTML and head and body tags and all that and then we can just extend the view from that we can also create custom components which we're not going to get into in this in this series so here's an example of a layout in blade so you can see we have HTML tags head tags body all that everything that you want on every single page and then we can put a title we can put a dynamic title in here we can add sections in this case there's a sidebar section and then we have the main content or the main view that's going to yield right here in this yield content so this is an example of a view that would extend that layout so all we have to do is say extends and then put in the file name we can add this section for in this case it's the title then we add the sidebar section we can bring in the parent which is the main layout sidebar and then we can add to it if we want so that this will only be displayed on this view all right and then we have the main content here all right so that's going to be it for the presentation now we're going to jump in and take a look at the application that we'll be building all right guys so this is the application will be building now we're going to have two main sections one is going to be the pages section we're going to have a pages controller and that's going to take care of things like the index page which you're looking at now the above page the services page and so on so that's what we'll start with and that's that's much simpler than getting into you know the crud functionality so once we do that we're going to get into the blog okay so we're going to create a post controller and we're going to be able to create read update and delete posts okay so this is the index page which will list the posts out if we click on one that will take us to you know that individual post and then once we get the crud functionality working we're going to then move on to two authentication all right so we're going to be able to register let's go ahead and actually I already have an account with my name let's let's say Steve Smith and the email address we'll just say test at test comm and then the password I think that's right all right so now that that went ahead and registered us and then it logs you in and you can see up here we have Steve Smith okay now notice that there's no blog post on our dashboard that's because only the posts that we create are going to show up on the dashboard so if we go ahead and create a post let's say blog post for and we'll just put something in here and I will just say this is my blog post and we can upload an image which I don't think I have any where are they right here actually yeah laravel images so I'm going to upload this Keystone image here these are just screenshots from some of my videos so we'll grab that will submit and now you can see we get a flash message up here post created there's our post right there you can say it's written it gives us the date gives us the user okay we're going to create a relationship between the users and the post okay now if we click on that notice now we have the edit and delete because we created this post so we can edit and delete it and if we go over here we can go to the dashboard and that will show all the posts we created okay so we can easily edit it we can easily delete it okay it gives us a little confirmation he'll say okay and now the post is deleted now although it looks very simple on the surface there's a lot we're going to get into we're going to cover all the fundamentals of laravel so hopefully you guys really enjoy this series and I will see you in the next video
Info
Channel: Traversy Media
Views: 1,077,119
Rating: 4.9501972 out of 5
Keywords: laravel, laravel from scratch, laravel series, laravel tutorial, laravel project, php, laravel php, php framework, mvc, model view controller, laravel 5, laravel 5.4
Id: EU7PRmCpx-0
Channel Id: undefined
Length: 17min 15sec (1035 seconds)
Published: Sat Jun 03 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.