Laravel is a web framework for making custom web base applications. It runs on PHP server side language, and is entirely free and open source. We’ll discuss what makes this framework a better choice, and why you might want to base your app on it.
What Is Laravel Used for?
Laravel is commonly used for building custom web application using PHP language. Laravel a web based framework that handles many things that are annoying to build yourself, such as controller, model, migration, routing, blade templating, middleware and authentication.
MVC is an architectural design pattern that helps to develop web applications faster. MVC stands for Model-View-Controller
Laravel is MVC pattern & Laravel is entirely server-side, due to running on PHP, and focuses heavily on data manipulation and sticking to a Model-View-Controller design. Laravel simply presents a solid foundation for you to build.
Laravel is one of the best PHP web frameworks in the world, but there are many other frameworks in different languages. Rails is another server-side rendered framework,Node.js, Express.js, Django, similar to Laravel, but based on Ruby. React, Vue, and Angular are all client-side JavaScript frameworks but can be configured to render server-side as well.
Alternatively, if you're leaning towards a blog-style application with multiple text-based posts, you can pull it off WordPress, which also runs on PHP Server side language. But Laravel doesn't force you to use features you don't want, That's why laravel framework is better, it gives you the tools to build something like WordPress on your own.
Laravel Build something awesome...
How Does Laravel Work?
Laravel uses a design pattern called Model-View-Controller, or MVC pattern.
The “Model” represents the shape of the data your application operates on. if you want make Model just command: php artisan make:model Model_Name, at a time you make migration file just -m text write. A Model is basically a way for querying data to and from the table in the database. Laravel provides a simple way to do that using Eloquent ORM (Object-Relational Mapping).
The “Controller” interacts with this model in Controller. if you make controller, just command: php artisan make:controller MyController . If a user requests to see their posts page, the controller talks to the model (often just the database). The controller contains most of the logic for your application. Just awesome
The controller uses that info to construct a “View.” The view is a template with which the model can be plugged into and displayed, and it can be manipulated by the controller. The view is all your application’s HTML components.
Laravel uses this structure to power custom application. It uses the Blade templating engine, It all starts with routes, defined in routes/web.php, that handle HTTP requests based on the location being requested. For example, the following function would run if a user requested https://yoursite.com/greeting:
Route::get('/greeting', function () {
return view('greeting', ['name' => 'James']);
});
This route executes a function that returns a view file from resources/views/. The view has been passed data (array or object), which it can use inside the markup file:
<!-- View stored in resources/views/greeting.blade.php -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h1>Hello, {{ $name }}</h1>
</body>
</html>
This is as simple as it gets, but a lot can happen in between the request and the return of a view. and also you return view file from controller and pass the data to retrieve object or array in the controller Laravel supports middleware, which will run before the request is handled. You could use this to lock down certain pages by checking if a user is authenticated before a request is handled.
How to Get Started
Laravel runs on PHP server side language, which means all you need is a web server like Apache or Nginx with PHP installed. optionally, if you can run on local server you can install Xampp, Wampp, Mampp etc.
You’ll also need Composer, a PHP dependency manager, and you’ll need a database. MySQL will work fine, but PostgreSQL and SQLite are supported as well.
You can download and install Laravel from Composer:
composer create-project laravel/laravel example-app
This creates a new directory named “example-app
” and installs Laravel to it.
PHP’s built-in Artisan server by running the following command in the project directory:
php artisan serve
This launches a development server at localhost:8000. If it’s running on a server, you’ll have to open that port like,
http://localhost:8000/
If you Learn Laravel you musty read Documentation
Laravel Tips and Tricks also follow our page and YouTube Channel.