Joke Collection Website - Blessing messages - Why Laravel became the most successful PHP framework?

Why Laravel became the most successful PHP framework?

Laravel has won wide attention because of its simplicity and elegance. No matter experts or novices, Laravel will be the first time when developing PHP projects. In this article, we will discuss why Laravel has become the most successful PHP framework.

modularity and extensibility

Laravel pays attention to the modularity and extensibility of code. You can find any file you want to add in the Packalyst directory which contains more than 55 packages. Laravel's goal is to enable you to find any file you want.

microservices and program interfaces

Lumen is a micro-framework derived from laravel and focused on simplification. Its high-performance programming interface allows you to develop micro-projects more simply and quickly. Lumen integrates all the important features of laravel with minimal configuration, and you can migrate the complete framework by copying the code to laravel project.

< ? php $app-> get('/', function() { return view('lumen'); }); $app-> post('framework/{id}', function($framework) { $this-> dispatch(new Energy($framework)); }); HTTP path

Laravel has a fast and efficient routing system similar to Ruby on Rails. It allows users to relate all parts of the application by entering the path in the browser.

Route::get('/', function () { return 'Hello World'; }); HTTP middleware

applications can be protected by middleware-middleware will handle the analysis and filtering of HTTP requests on the server. You can install middleware to verify registered users and avoid problems such as cross-site scripting (XSS) or other security issues.

< ? php namespace App\Http\Middleware; use Closure; class OldMiddleware { public function handle($request, Closure $next) { if ($request-> input('age') < = 2) { return redirect('home'); } return $next($request); }} Cache

Your application can get a robust cache system. By adjusting it, the application can be loaded more quickly, which can provide your users with the best experience.

Cache::extend('mongo', function($app) { return Cache::repository(new MongoStore); }); Authentication

security is crucial. Laravel comes with authentication for local users and can use the "remember" option to remember users. It also allows you to, for example, some additional parameters, such as whether the display is an active user.

if (Auth::attempt(['email' => $email, 'password' => $password, 'active' => 1], $ remember)) {//The user is being remembered ...} Category integration

Laravel Cashier can meet all the needs you need to develop a payment system. In addition, it is synchronized and integrated into a user authentication system. Therefore, you no longer need to worry about how to integrate the billing system into the development.

$user = User::find(1); $user-> subion('monthly')-> create($creditCardToken); Task automation

Elixir is a Laravel program interface that allows us to define tasks with Gulp. We can use Elixir to define preprocessors that can streamline CSS and Java.

elixir(function(mix) { mix.browserify('main.js'); }); Encryption

A secure application should be able to encrypt data. With Laravel, you can enable the OpenSSL security encryption algorithm AES-256-CBC to meet all your needs. In addition, all encrypted values are signed by a verification code that detects whether the encrypted information has been changed.

use Illuminate\Contracts\Encryption\DecryptException; try { $decrypted = Crypt::decrypt($encryptedValue); } catch (decrypt exception $ e) {/} event handling

The definition, recording and listening of events in the application are very fast. The listen in the EventServiceProvider event contains a list of all the events recorded in your application.

protected $listen = [ 'App\Events\PodcastWasPurchased' => [ 'App\Listeners\EmailPurchaseConfirmation', ], ]; Paging

Paging in Laravel is very easy because it can generate a series of links according to the current page of the user's browser.

< ? php namespace App\Http\Controllers; use DB; use App\Http\Controllers\Controller; class UserController extends Controller { public function index() { $users = DB::table('users')-> paginate(15); return view('user.index', ['users' => $users]); }} Object Relation Diagram (ORM)

Laravel contains a layer dealing with database, and its object relation diagram is called Eloquent. In addition, this object relationship diagram is also applicable to PostgreSQL.

$users = User::where('votes', '>' , 1)-> take(1)-> get(); foreach ($users as $user) { var_dump($user-> name); Unit test

The development of unit test is a time-consuming task, but it is the key to keep our application working normally. PHPUnit can be used to perform unit tests in Laravel.

< php use Illuminate\Foundation\Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\DatabaseTransactions; class ExampleTest extends TestCase { public function testBasicExample() { $this-> visit('/') -> see('Laravel 5') -> dontSee('Rails'); }} To-do list

Laravel provides the option of using to-do list to deal with complex and long processes in the background. It allows us to handle certain processes asynchronously without the continuous navigation of users.

more information