Unlimited Plugins, WordPress themes, videos & courses! Unlimited asset downloads! From $16.50/m

Next lesson playing in 5 seconds


Free Preview: Build a CMS With Laravel


  • Overview
  • Transcript

Laravel is a PHP framework for modern web apps. Now on version 5, it’s a mature system that continues to win support due to its elegance and stability. Laravel ships with built-in support for database migrations, object-relational mapping, routing, and authentication, making it easier for developers to start and maintain their work.

In this course, Envato Tuts+ instructor Jeremy McPeak will show you how to build a complete content management system (CMS) with the Laravel PHP framework. You’ll learn some of the tasks and problems that are common to so many web development projects, and you’ll explore different possible solutions to them. You’ll be creating your CMS from scratch—complete with page, user, and blog management capabilities. This is a great way to expand your knowledge of the Laravel framework!

If you haven’t used Laravel before, why not check out our full course and learn Laravel 5: Get Started With Laravel 5. If you’ve mastered the fundamentals of Laravel, build on your experience with these courses:

1. Introduction

1.1 Introduction

So you want to build a content management system with Laravel. Well, I can't blame you because it's an excellent way to learn not just Laravel, but how to build applications. Hi, I am Jeremy McPeak, and I invite you to spend the next few hours with me as I build a CMS from scratch. Now, this isn't just some simple blog engine. This CMS will let users define, sort, and nest individual pages, manage users and, yes, manage blog posts. So, we'll begin at the very beginning. We'll design our database schema, and we'll use Laravel's artisan to make our migrations and seed our database with its initial data. From there,we'll build our admin portal where we can create, read, update, and delete individual pages. We'll be able to manage our users with a role based security system, and of course, manage our blog posts. And during all of this, you'll learn about Laravel's features, such as policies to control what users can and can't do with the application. You'll learn about view composers to provide extra data to views. And we'll even talk about the presenter pattern to take some of the logic from outside of the view. By the end of this course, you'll be comfortable with basic CRUD operations, user management, and security, and much more. So when you're ready, queue up the next video and we will get started.

2. Getting Started

2.1 Creating the Project

Obviously, the very first thing that we need to do is create our project. But before we even do that, we need to talk about our environment, because we can approach our environment in a variety of different ways. Now of course, you need PHP, you need some kind of database and we're going to be using MySQL in this course. And you could also use an HTTP server. Now that latter thing isn't as crucial because we can use the server with PHP in Artisan. But we definitely need PHP, we also need a database. So you can install those things and configure them if that's what you want to do. But you can also use a tool that is going to give you everything that you need out of the box. One of those is called Homestead. This is a virtual machine, which is very nice because it keeps your development environment well isolated from everything else. If you are especially developing with multiple technologies on multiple different platforms, it is a really good idea to use a virtual machine. That way you can fire up whatever virtual machine you need for whatever technology or platform, and you're good to go. So Laravel is one of the solutions and it uses something called Vagrant. Now, I'm not going to go over all of the installation steps required for setting up Homestead. But, this is what I recommend for you, for your laravel development. The actual URL here really depends upon the version, of Laravel. The current version is 5.5, so this is laravel.com/docs/5.5/homestead. However, if you just do a search for laravel homestead, chances are very good that the first option is going to be for the latest version. Of course you can always go to the documentation, choose your version, and then you're good to go there. So just follow the instructions, and you'll be good to go as far as Homestead is concerned. Now as far as my environment, I'm using something called MAMP. This is not a virtual machine, this is a tool that installs PHP, MySQL, Apache and a variety of other things. Now, the reason why I'm using MAMP is because what you see on screen here is a virtual machine. So, if inception taught us anything, it is that we don't run a virtual machine inside of another virtual machine, if we want any type of performance. So, that is why I'm using something other than Homestead, but I highly recommend that you use Homestead for you Laravel development. Okay, so we want to create a Laravel project, but in order to do that we need Laravel. So we can get Laravel by using a tool called Composer. If you go to getcomposer.org, then this will take you of course to the website. And this avatar will be different based upon whenever you load it. You can see that I'm just refreshing, and it's going to look a little bit different. But that doesn't matter, what you want to download and install Composer. It's a very straightforward installation, and once you have it, then you are ready to start creating your Laravel project. So the first thing we need to do is install Laravel, and we can do that in a couple of different ways. The first thing we can do is run composer, we say composer global require and then we will say laravel/installer. This is going to install the installer for Laravel. This is going to cache everything so that we can just use the Laravel new command in order to create our project, and everything is going to go from there. The other option is to simply use composer. You would say composer create-project, and then you would say prefer-dist larvel/larvel and then the name of your project. We're going to call this LaraCMS. So either way, you're going to end up with a project. Since I have Larvel installed, I'm just going to say larvel new LaraCMS, that's just a lot easier to type. After we create our project, we of course want to open it up in our code editor of choice, because we want to modify the .ENV file. This is a file that contains settings for our environment. This is a development environment, so all of the settings here are for our development environment. But whenever we decide to push it out into production, we could either change the settings inside of this .ENV file. Or we can have a completely separate file that contains all of our production environment settings. It makes us so that we can change these important settings for whatever environments that we need. Now in our case we want to change the data base name. Our database is going to be called laracms, or you can can call it whatever you want, it really doesn't matter. I'm just going to keep the name of the database the same as our project. And if you're using homestead then that's pretty much it. Since I'm not, there's a few other settings that I need to change. My port is 8889, my user name is root, and my password is root. But once you make the necessary changes for your environment, you are pretty much good to go. So that in the next lesson we can get started creating our database schemer, and we're going to do that using migrations.