We like to call Laravel a “progressive” framework. By that, we mean that it grows with you when building SaaS with Laravel. If you’re just taking your first steps into web development, its vast library of documentation, guides, and video tutorials will help you understand the framework functionalities.
Table of contents
- What is Laravel and how does it work?
- How to install Laravel on a VPS?
- Create a new project with Laravel
- Build and deploy your first SaaS
- Automated deploys with Docker
- Conclusion
What is Laravel and how does it work?
Laravel is a free and open-source PHP Framework for Web Artisans based on Symfony that helps craft Web Applications following the MVC (Model View Controller) design pattern.
This framework is a web application framework with expressive, elegant syntax. A web framework provides a structure and starting point for creating your application, allowing you to focus on creating something amazing while we sweat the details.
Furthermore, it strives to provide an amazing developer experience while providing powerful features such as thorough dependency injection, an expressive database abstraction layer, queues and scheduled jobs, unit and integration testing, and more.
There are a variety of tools and frameworks available to you when building a web application. However, we believe Laravel is the best choice for building modern, full-stack web applications.
How to install Laravel on a VPS?
Installing Laravel on a VPS, on a dedicated server, or locally on your computer first requires you to install php v8.*. It is up to you to determine whether your web server shall use Apache or nginx, or whether you want to deploy your web application using Docker or docker-compose.
Create a new project with Laravel
The simplest installation goes through composer, which is a package registry that is very popular amongst PHP developers. Composer is open source and can be installed on any major operating system:
# Create a folder for your project
$ mkdir -p my-websoftware
# Use composer to create a laravel project
$ composer create-project laravel/laravel:^9.0 my-websoftware
That’s already it for the creation of your project. Now you would typically be adding dependencies and developing your innovative features. But more importantly, you will have to configure your MySQL database access such that Laravel can communicate with it.
First, copy the .env.example file to .env, e.g. using: cp .env.example .env
. Then, open it and edit the following fields with correct database values:
# Configure your app name
APP_NAME = "My Awesome App"
# Configure the MySQL database values
DB_DATABASE=db_mywebsoftware
DB_USERNAME=root
DB_PASSWORD=
Build and deploy your first SaaS
Building your software revolves around some configuration tools that are available with Laravel out-of-the-box. In fact, you can use the php artisan list command to find out about all the command line tools that are available to manage your web application and database.
# List all the available commands
$ php artisan list
# Deploy your software / API
$ php artisan serve
Automated deploys with Docker
The framework is also compatible with Docker, of course. So if you ever wondered how to automate deploys of your SaaS with Laravel software with Docker, this is the right place to be.
In fact, everything that is needed to run your web application using Docker, is available out-of-the-box with this amazing framework. After having installed the dependencies for the framework, all you need to execute the Docker containers is one command:
# Start the Docker containers
$ ./vendor/bin/sail up
Conclusion
If you are looking for a framework that is both secure and efficient, building SaaS with Laravel is probably your best bet. We have been using this framework for more than a decade now, and have always been amazed and the vast feature set available out-of-the-box.
We believe that this framework has a lot of potential for any type of custom web applications and have used it in many production software before.
[…] are looking for another framework to develop your web application, I recommend that you have a read here, with details on how to build your own SaaS with Laravel and […]
[…] how to build a SaaS with Laravel, to achieve this I’d recommend that you first have a read here. The frontend that we will install, shall work with Laravel resources, using a RESTful HTTP API […]