Laravel is a powerful web framework developed with PHP that allows developers to spend less time laying down the foundation of the project and spend more time in the actual development. It already comes with a lot of the basics pre-configured, things like database connections, mailing, authentication, translations, template engine, Vue.JS pre-installed, and many more that demand time to configure every time you start a new project.
The framework also follows the MVC (Model-view-controller) pattern, the most popular in web development, giving you the tools to write more clear and efficient code. The goal of this article is to guide you through the steps of installing, configuring, and starting your project with Laravel.
Laravel offers you the Laravel Homestead, an Ubuntu virtual machine that includes all the software you need, such as Apache, Nginx, Git, PHP, and MySQL. Although it is good to start with this approach, I’ll focus on the most universal path for starting to use Laravel, but feel free to check out the Homestead and see if it can be of use to you.
To start with Laravel without the Homestead you will need to have PHP installed—Laravel works with different PHP versions, but here we will focus on PHP 7+. There are many ways to install PHP: you can install it stand-alone with a web server of choice (if you are a Linux or Mac user you can follow the LAMP or MAMP software stack) or with web servers stacks packages such as XAMPP, WAMP or EasyPHP. All of these options come with a web server (Apache or Nginx) and SQL database, and most import PHP. This should include all of the essentials you need to start using Laravel.
After installing PHP, make sure you have the following extensions. All of them are required for Laravel to work with its full capacity (depending on the framework’s version):
Now that you have PHP installed, we can move to the next step. To install Laravel you will need to first install Composer, a dependency management tool for PHP (can also be used to install any missing extensions). For Windows users, you just need to download and run the Composer setup. If you are on Linux or Mac, you can follow the command lines below:
After this open your command prompt/terminal and type:
Wait for the Laravel installation to finish, then navigate to the folder where you want to start your project and type:
Alternatively (or if your system can’t find the Laravel command), you can also use Composer for this by typing:
Once you finish this step you will have your Laravel project working and ready to start developing. You can use Apache/Nginx to serve your application or you can use the command “php artisan serve” PHP’s built-in development server. Sometimes less is better
As mentioned before Laravel comes with lots of resources, but what if you don’t need all of them? What if you just want to develop an API or you want to build something small and Laravel seems overwhelming?
For scenarios like this, Laravel has a micro version called Lumen with only the essential features you will need to develop APIs and Web services. The steps to install Lumen are the same as those for Laravel, you just have to replace some names as you can see in the commands below.
Starting project with Lumen:
Starting project with Composer:
Besides these small changes, the rest of the installation process and tools will be the same. You will only need three PHP extensions this time.
Laravel provides a basic start for front-end to quickly begin developing with Bootstrap and React or Vue. For this, you have to first install the laravel/ui package with Composer. See the steps below:
Once the ui package is installed, you can proceed to install the front-end packages.
Basic installation:
Installation with authentication system:
*This doesn’t mean that you can only use these three options. You can also use Angular or any other front-end framework with Laravel; these are just suggestions that Laravel brings ready to go.
Laravel is a very powerful and popular framework, it can be used for small and big projects and has all the features you will need and many more services to offer. The Laravel ecosystem also offers lots of tools like Nova (an admin panel), Telescope (a debug assistant), Echo (to handle real-time events), and many other tools to take you even further. The framework’s documentation is very straightforward and simple to understand, and the community around it is very active and helpful.