Laravel framework is one of the most popular frameworks at the moment. The framework has earned its popularity due to the rapid development, the built-in script and styles, and most importantly, its own and very convenient template engine. On top of that, a very flexible formation of routes, which is undoubtedly a huge plus.

Official documentation is best suited to learn Laravel. Moreover, an excellent video course from Laracasts is an integral part of studying this framework. This is a beautiful resource. With it, you can find not only useful video tutorials on the Laravel framework. But also additional tools for developing a full web application based on Laravel. That in addition to solid principles in PHP for correct construction of your application, and video tutorials on Vue.js framework, which I recommend as the front-end part of your web application.

Blade is the simple but fantastic templating engine provided with Laravel.

THE BLADE TEMPLATING ENGINE

One significant plus in Laravel is its blade templating engine.

After successfully reading the documentation and watching the video course, you will be ready to create a web application. This process is very entertaining and absorbs you completely. For example, we take the construction of a blog with the possibility of expanding it to the web store, as implemented in WordPress + Woocommerce.

The best practice will be to use a modular system for building an application. This is very convenient and most importantly, a proper hierarchy of all your files, which is an advantage if other developers will use your code in the future. Best of all, you will learn to order in your web application.

Now we come to one of the most important things in this learning experience: creating a database for a future web application. On the one hand, the database should be straightforward. On the other hand, it has to be quite flexible.

In the database, we will need to keep a lot of different data, such as data of users, posts, pages, categories, tags, comments, user roles and user permissions. A wise thing to do is to the good is to create a table for the media library, and maintain a connection between media files on your disk and some posts. Then, once a month, you can delete all media files, but not media which were uploaded previously and belong to some pages, posts or products. And for the store, we should also keep data categories of tags and prices: the standard price and the discount price. For all of that, we need different tables in our database.

Laravel has a command line interface through which you can create all the necessary files for work, such as modules, controllers, models, migrations, etc.

 

It describes what is the creation process using Laravel

THE CREATION PROCESS

The creation process is straightforward. We create a migration path for the user table via the command line interface (there is a standard artisan command). Then we need to create a controller, model, and migration for roles, user permissions, and then for user roles. We do all that so in the end, we can connect everything. And in the future, each user will have a role, and each, in turn, will have its permissions for the user.

If using a standard command to create a controller, model and migration, there will not be enough fields in the new table for the user in the migration file. For this specific reason, the first thing we need to do is add the missing fields.

Another important feature is to realize the activation of the user account. For this, there are two ways. The first way is to activate it through Laravel. The second way is to enable it on its own, which is not difficult. When using the standard method through Laravel, you speed up the development process, because everything is written thinking of you. This is a massive advantage of this framework in comparison with the rest.
Once all of the above has been completed, you can begin installing a modular system for a web application.

a ladder showing growth in the corporate world

THE MODULAR SYSTEM

The modular system in Laravel is an add-on that is installed via composer, after which new commands are automatically added to the command line interface. That can be used to create, enable or disable modules. There are many commands added. I just listed a few of them.

Now you can create modules. You can find detailed commands here.

At this stage it is necessary to create several modules:

  • Administrative panel module;
  • Site module;
  • Blog module;
  • Store module;

After building all these modules, I would recommend creating your middleware. That will allow you to filter http requests (for example, give access to a specific group of routes and filter all requests to access the administrative panel).

WHAT ARE ROUTE GROUPS AND HOW TO BEST USE THEM

Route groups is a process that happens when we combine different routes into one group. We filter all http requests through this group using middleware. It is more logical and convenient when there is a need to filter all routes according to the same rules for different methods and controllers.

One of the necessities for any form is validation. And here Laravel provides us with two options. We can do it directly in the Controller for each method, or we can use special classes. Doing that, we will be able to pass requests and still in this class write validation for forms. In this case, there is no universal method, and everyone chooses your preferred method.

Also in this framework, there is a beautiful thing from the box, like flash messages, that we can return after working out any of the methods with a simple command. For example, show the user that the form was submitted successfully or not.

Laravel + VUE.JS

Laravel works excellent with the front-end framework Vue.js and this link allows you to make genuinely excellent web applications. For example, to create a spa application where Laravel will be responsible for the back-end, and Vue.js will be responsible for the front-end.

In such a bundle of frameworks, we get an application that works very quickly. That, in the end, will please not only you but also the users who will use your web application. As with proper construction, you can eliminate many unnecessary page reloads and implement form validation on the fly.

At that moment, when the user is just beginning to enter data into the form fields, validation is already taking place. And it happens on Laravel. The returned results are done not by Vue.js, but by Laravel.

When you start writing Laravel, you will not stop anymore. It’s addictive; trust me. After working with this framework, it will be hard to abandon it and switch to something else.

I hope you enjoyed this step-by-step guide to Laravel. My name is Vitaliy. I’m a PHP developer, a Laravel lover, and I’m part of the 247 Labs team.

I would love to hear your feedback. Please send me a message with your comments. Don’t forget to mention my name. And thank you for sticking with me until the end of this text. I hope you enjoyed it as I did.