Last updated: March 12, 2020
What Is a PHP Framework?
A PHP framework is a suite of tools and templates for developing software applications.
It includes a methodology for organizing the code and designing the system architecture.
What is the Model-View-Controller Paradigm?
Laravel is a PHP framework built on the Model–View–Controller (MVC) paradigm. This is an approach towards application structuring that maintains the data, display, and business logic separately.
|Model||Defines data object types|
|View||Templates that present the data in a specific way|
|Controller||Controls application logic|
The Model is the data model. This is the code that defines the types of data objects the system will keep track of, as well as their attributes and relationships to each other.
The code in the model (along with basic utility classes in the core of Laravel) specifies how the application will interact with the database.
Laravel provides a “database abstraction layer,” which is a generic coding interface to a number of different supported database systems. Because of this, the primary data model (the Object Relational Model) is written directly into the application code, not in SQL.
An Interface With Purpose
The Model also provides an interface for updating the data associated with any object. It also syncs those updates to the database or other data persistence layer. This interface is accessed primarily by the Controller.
The View is a system of templates that present data from the model in a specified way, including:
- An HTML page viewable from a web browser
- A public data API
- An RSS feed
- Email templates, and
- Printed documents.
How Does The View Present Data?
The View does not manipulate data, it merely receives it from the Model and displays it as specified. This ensures that if you are (for example) looking at an analysis of site traffic, the data is exactly the same whether you view it as a list, a graph, or a pie chart.
The Controller handles all the application logic. This begins with the connection between the Model and the View, as well as the connection to the web server or some other source of requests.
The Controller also handles any special conditional features. For example, if you want an email to be sent when a specific action occurs, that email is triggered by the Controller. (The Controller will no doubt receive information about the contents and recipient of the email from the Model. In turn, the View will provide the template for the actual message.)
When building a new web application in PHP, there are a number of common features that need to be included no matter what the application’s core functionality is.
This “boilerplate” development includes complex activities, such as user and session management. It also includes fundamental utility code, such as connecting with a database.
Very few developers really enjoy coding these types of features. It’s a lot of complicated and exacting work.
This is where PHP frameworks like Laravel come in handy.
Laravel and Basic App Features
Laravel modules provide all the core features that every web application needs, such as a database abstraction layer and user login.
Laravel takes this a step further and offers additional modules for commonly needed functionalities, including event listeners and the Laravel Cashier module for payment processing.
Even better, because Laravel uses Composer for package management, it is easy for developers to create, and for other developers to include generalized feature sets.
This is especially useful for software development teams building multiple apps in a related industry; domain-specific features can easily be modularized and included in multiple projects.
Developers building a new web application have an almost unlimited number of ways of designing the system and organizing their code. This complete freedom is the source of the great potential of software — anything is possible.
But this is also the source of many project failures and delays — anything bad is likewise possible. Rarely will a developer need to build an application for such an incredibly novel function that an entirely new approach is needed; rarer still will such an app be coded in PHP.
So it makes sense that a good web app framework would provide exactly what its name implies: a frame of an application that works for most developers, most of the time.
Laravel is strongly oriented toward best practices and a logically sensible architecture. Proof of this can be found in Artisan, Laravel’s command-line interface. Artisan automatically provides developers with helpful commands while coding
It isn’t just boilerplate features that require the use of a boilerplate code. The development of new functionality can often be equally tedious.
For example, imagine you are building a management application for an auto repair shop. You’ll want to create a class of data objects that keep track of vehicles. But you don’t just have to create a new class. You’ll also need to create the following:
- A View for Vehicles, as you’ll surely want to display a screen that shows the details of any specific vehicle;
- An index View to see a list of multiple vehicles at the same time;
- A route in the Controller for each of these, since their existence will be moot if your user can’t get to them;
- And finally, a way to confirm that all these different pieces of code all work together properly, so that you don’t misspell “vehicle” in one file or use the singular when you should have used the plural.
How Much Coding Is There To Do?
The Laravel framework provides a command line interface (CLI) that allows you to scaffold up code quickly.
All you do is declare the new model; the framework creates the various files and code blocks that are needed.
Of course, you still have to fill these in with the real code, but all the elements and the connections between them are pre-built.
Looking for a great deal on Laravel web hosting?
A2 Hosting scored #1 in our recent speed and performance tests. With their plans, you can set up Laravel with a single click and get free website migration. Right now you can save up to 50% on A2 Hosting. Use this discount link to get the deal.
Laravel Web Hosting
There are multiple considerations and tasks involved in provisioning and managing servers and deploying your app optimally.
Deploy PHP Apps Fast with Forge
You can provision and manage cloud servers in seconds with Laravel’s Forge service.
We provisioned a custom VPS server in under 60 seconds with a few clicks.
Forge also enables you to have SSH keys added automatically to every server you create. And you can connect to GitHub, GitLab, or Bitbucket and push to deploy — straight from the Forge dashboard.
Vapor is an AWS-powered serverless platform that offers fast scalability, easy setup, and is designed to work seamlessly with Laravel.
Deploying PHP Apps Without Forge or Vapor
If you’re not a Forge user, the critical issue for developing and hosting a Laravel application will be your ability to install and configure software on your server yourself.
Enable SSH Access
First, enable SSH access on your server. You can do this through the control panel. This lets you quickly add the framework and associated tools.
MCrypt and Databases
Laravel runs on PHP 5.4+ and requires the MCrypt extension.
Depending on the type of application you are building, you will need a database management system of some sort. The exact choice is up to you, although several are supported.
Moreover, you will need to think about which applications need to be installed on your server.
How Do I Install Laravel?
You can install Laravel in one of two ways: manually or through the Softaculous installer software.
Related applications, libraries, and dependencies will then be handled by the Composer dependency management tool that Laravel requires.
You will also need SSH access in order to sync your Git repository to your server. With each of these three essential pieces enabled for your PHP workflow, you’ll be able to build, test, and deploy projects more easily.
Do I Need VPS or a Dedicated Server?
Note that not all shared hosting plans provide this level of control and access to the server environment. As a result, you may need to use a VPS account or run your own dedicated server to code with the Laravel web app framework.
Laravel Hosting Summary
Sophisticated syntax and model-view-controller organized structuring make the Laravel framework a powerful weapon in your coding arsenal.
Not every web hosting company or plan type will be suitable for working with the Laravel framework. Start by defining your goals carefully, then choose a web hosting plan that best aligns with them.
Looking for the right Laravel host?
InMotion Hosting offers a wide variety of quality plans. They provide one-click installation of Laravel. Save big on this host, by using this special discount link . P.S. – They’re rated A+ by the Better Business Bureau.
Laravel Frequently Asked Questions
- Can Laravel run on shared hosting?
Laravel can run on shared hosting if your provider offers you the permissions you need to set it up. If that’s the case, you will need to compile the assets for your applications locally, then upload them to your hosting environment via FTP.
However, Laravel developers report mixed results when trying to deploy to shared hosting. The bottom line is that Laravel isn’t really designed to work on shared hosting. We believe it’s a better idea to use a VPS server for your Laravel projects.
- Who uses Laravel?
In addition to being popular with individual developers and small-to-medium sized businesses, Laravel is used by organizations like Pfizer (a pharmaceuticals company), the BBC (British Broadcasting Company), Invoice Ninja, Flarum.org (forums), October CMS, and 9GAG (an online platform and social media company).
- What is Laravel Spark?
Spark is a Laravel package that provides a “scaffold” of reusable code boilerplate so you can build SaaS applications quickly. For example, it provides out-of-the-box user authentication, password resetting, teams, profile photos along with e-commerce features like coupons, invoices, subscription plans, payments, and logic for teams. With Spark you’ll also get access to a SaaS landing page.
- What is Laravel Envoyer?
Laravel Envoyer is a tool that by that enables you to easily deploy your code to one or more servers with no downtime. It integrates with popular code repositories like Github and BitBucket and communication tools like Slack. You can use Envoyer in conjunction with Laravel Forge to create PHP servers, but it’s not necessary. Envoyer includes rollbacks.
- How do I host a GoDaddy Laravel project?
To host a Laravel project with GoDaddy, you’ll first need to purchase a domain and a hosting account . Next, log in to your cPanel dashboard to enable SSH access on your hosting account. (GoDaddy disables this by default.) Use SSH access to install Composer first, and then install Laravel. At this point, you can configure your Laravel environment and set up your website/application.
- How much does Laravel cost?
The Laravel framework is open source and free to use. However, there will likely be ancillary costs for launching a Laravel project. Popular tools like Laravel Forge (deployment tool) and Laravel Vapor (for autoscaling) incur monthly fees. Remember to calculate your hosting costs. If you’re planning on hiring a developer, then obtain some estimates and add those to your calculations.
- Which is better Laravel or WordPress?
Whether or not Laravel is a better choice than WordPress depends on multiple factors, including the type of site you wish to build, the level of customization and functionality required, and the future plans for the website. For example, Laravel can be a wise choice for sites requiring future and/or complex customization. WordPress is a highly popular and easy-to use CMS. But it can be challenging to maintain given the monolithic size of its code base.
Before choosing Laravel or WordPress, gather the requirements of the project and go through a discovery phase with the website customer. Include budget in your decision making: Laravel projects tend to cost more at the outset, while WordPress projects are typically less expensive at the outset, and more expensive later if complex changes are required.
- What are Laravel packages?
A Laravel package, like all code packages, is a bundle of re-usable code that solves common problems. Code packages save developers time by ensuring they don’t have to build common functions and features from scratch. Some popular Laravel packages include Entrust (for role-based permissions), Socialite (for OAuth authentication), and Laravel Telescope (a debugger).
- What are the Laravel installation requirements?
The Laravel framework system requirements can be met by using the Laravel Homestead virtual machine as your local development environment. If you are not using Homestead, you will need to make sure your server is running PHP 7.1.3 or higher, and running a set of required extensions.
Those required extensions are:
- OpenSSL PHP Extension
- PDO PHP Extension
- BCMath PHP Extension
- Ctype PHP Extension
- JSON PHP Extension
- Mbstring PHP Extension
- Tokenizer PHP Extension
- XML PHP Extensio
You will also need to install Composer, before installing Laravel, in order to manage your dependencies.
- How do I get and install Laravel?
You can install Laravel locally by executing a series of commands via your command line interface (terminal). First you’ll need to install Composer, which will be used to manage your dependencies. Next, install Laravel using this command:
composer global require laravel/installer
If you need to install Laravel from a hosting account, and have cPanel, it's likely you can use Softaculous to install Laravel with one click. If your web host does not provide Softaculous or Installatron, check their help documentation for instructions on installing Laravel.
- Can I run Laravel on a Windows server?
Yes, you can install Laravel on a Windows server. Keep in mind that the large majority of Laravel users are working with Linux servers. So if you run into trouble running Laravel on a Windows server you will have a harder time finding help than if you set up Laravel on a Linux server.
- What kind of applications can you build with Laravel?
Laravel is designed to build web applications based on a model-view-controller (MVC) architecture. That leaves the door open to a lot of different types of web-based applications. Any web application that deals with data that can easily be broken into consistent objects is a candidate for Laravel.
For example, Laravel has been used to build reservation systems like AirportParkingReservations.com, classified listing sites like HomeListingsFinder.com, e-commerce sites like rv.CampingWorld.com, and directories like ExploreGeorgia.org.
- Is Laravel getting more popular?
According to BuiltWith.com, Laravel has steadily grown in popularity since 2013. It is currently used by over 8,000 of the top one million sites. There are more than 160,000 active sites using Laravel and it's been deployed on more than 1 million projects.
- Why should I avoid using Laravel?
Whether or not you should "avoid Laravel" will depend on the type of project you're working on and your own preferences. Developers form their own opinions about all frameworks, and each framework has supporters and detractors. You can read some sample criticisms of Laravel here and here. And you can read some sample praise of the framework here and here.
- What are some alternatives to Laravel?
There are lots of PHP frameworks you could consider if you're looking for an alternative to Laravel. Start your search by researching CodeIgniter, Symfony, Zend, Yii, Phalcon, FuelPHP, CakePHP, PHPixie, Slim, Aura, Kohana, Flight. Medoo, POP PHP, Simple MVC, Fat-free, PHP Mini, Zikula, and YAF.
- What is Laravel?
Laravel is a PHP web application framework. It's a set of tools designed to make building a web application with PHP easier and faster, and produce a final product that is secure and follows best practices. Laravel has been dubbed the "PHP Framework For Web Artisans" because of its versatility. It can be used for front-end and back-end solutions.
- What's the benefit of using a programming framework?
A good framework like Laravel will take care of a lot of the boilerplate work that goes into creating virtually any web application. It will also help you avoid certain coding pitfalls. Frameworks are designed to encourage best practices and to help developers save time.
- Do I need to use a programming framework?
No, you don’t need to use a framework. But frameworks can dramatically improve efficiency, quality, and speed of development. Frameworks also tend to lower developemnt costs for customers. That said, some developers believe frameworks add unnecessary complexity in the form of overhead and dependencies. These purists encourage other developers to avoid using frameworks.
- Where can I find Laravel packages?
Laravel packages can be found in one of two places: Github or Packalyst. Start at Packalyst, which is a directory of Laravel packages. There you'll find thousands of Laravel packages which you can sort by popularity or age, and search by keyword or tag.