Laravel 5.8 Chinese Documentation Manual

Read(114147) update time(2022-04-15)

"Laravel 5.1/5.8 Cheatsheet: https://www.php.cn/phpkj/laravel/cheatsheet58.html" Manual introduction: Laravel 5.8 continues to optimize on the basis of Laravel 5.7, including the introduction of new Eloquent relationships ( has-one-through), optimize email verification, automatic registration of authorization policy classes based on agreement, DynamoDB cache and Session driver, optimize time zone configuration of task scheduler, support assigning multiple authentication guards to broadcast channels, PSR-16 cache driver specification etc.


Laravel is a free and open source PHP Web framework created by Taylor Otwell. It is designed to implement the MVC architecture of Web software and serve as an alternative to CodeIgniter. Its source code is hosted on GitHub, and the license terms are MIT license.

The latest course: php Chinese website "Laravel Basics to Comprehensive Practical Online Live Class" is now open for registration!

Laravel features include: support for user authentication and permissions, a modular package system with a dedicated package library, ways to connect to many types of relational databases, and tools to assist applications Deployment and maintenance of programs, and the development of many syntactic sugars.

Laravel is considered one of the most popular PHP frameworks along with Symfony, Zend, CodeIgniter, Yii2 and other frameworks.

Tips: Before continuing to learn the laravel framework, you need to have a basic understanding of the PHP language.

Function

The following points are the core design concepts of Laravel

  • Bundles: The package management system provided by Laravel 3 allows Developers can easily extend some of the suite's functionality into their projects. Laravel 4 goes a step further by using Composer to manage dependencies between packages, making it possible to install PHP packages that are generally used in various frameworks or Laravel-specific from Packagist.

  • Eloquent ORM (Object Relational Mapping): Implements Active Record mode in PHP and provides some functions to create relationships between database objects. Following the principles of the Active Record pattern, Eloquent ORM uses categories to represent data tables, and binds object instances of these categories to a single piece of data in the data table.

  • Query builder: Released in Laravel 3, providing a more direct pipeline to access the Eloquent ORM. Rather than writing SQL query syntax, Laravel's query builder provides a series of classes and functions that can be used to run SQL queries using programmatic calls. At the same time, the running results of the query syntax can also be cached (which can be queried again).

  • Application logic: Integrate other developed functions in the project. The obvious cases are the use of Controller and the declaration of routes. Its syntax is similar to the Sinatra framework.

  • Reverse routing: Create routes one by one for the hyperlinks in the project. When the hyperlinks applied to the route are modified, all hyperlinks using the route will be automatically updated. . When using, you need to fill in the names of the routes you want to use, and Laravel will convert them into corresponding URIs.

  • Restful controllers: Provide a way to separate the logic behind HTTP GET and POST requests.

  • Class auto loading: It can automatically load PHP categories, eliminating the trouble of manually maintaining the reference paths of all categories. Categories will only be loaded when they are used, thus avoiding unnecessary loading of categories.

  • View composers: are customizable code blocks that will be run when the view is loaded.

  • Database seeding: Provides a pipeline to populate the database with default data to facilitate software testing, or as an initial application build step.

  • Unit testing has also been integrated into Laravel, which includes test cases that can detect and prevent regressions within the framework, and can use the Artisan CLI to run unit tests.

  • Homestead: A Vagrant virtual machine, preloaded with all the development tools needed by Laravel developers, including Ubuntu, Gulp, Bower and other tools to assist web development.

Tips: Our Laravel 5.8 tutorial will help you learn Laravel knowledge from beginner to advanced. If you have any questions, please go to the PHP Chinese website Laravel Community to ask your questions, and enthusiastic netizens will answer them for you.

Officially provided packages

The following modules can be installed through composer and packagist:

  • ##Cashier was launched in Laravel 4.2 and can be connected in series Subscription-based payment services such as Stripe provide features such as coupons and receipts.

  • SSH, introduced in Laravel 4.1, allows programs to run CLI commands on remote servers through SSH.

  • Scheduler, launched in Laravel 5.0, can schedule Artisan instructions to run cronjob through the program, but it still needs to rely on the Cron daemon.

  • Flysystem, launched in Laravel 5.0, unifies the file system functions to make the operation logic of local and cloud storage spaces (such as Amazon S3, Rackspace Cloud) consistent.

  • Socialite, launched in Laravel 5.0, simplifies the process of connecting OAuth and provides platforms such as Facebook, Twitter, Google, GitHub and Bitbucket, etc. :13

Artisan CLI

Laravel's command line interface (CLI), called Artisan, was quite limited when Laravel 3 was launched. Later, Laravel changed its architecture to use Composer as the base, allowing Artisan to complement the components of the Symfony framework. Therefore, Artisan in Laravel 4 provides more functions.

Artisan's functionality is spread out into different subcommands to help create and manage software built with Laravel. The most common usage scenarios include: operating database migration & seeding, extracting static resources from packages, and generating code templates for newly created controllers or migrations (saving developers the time of repeatedly writing the same code). Developers can also add new commands to extend the functionality of Artisan (such as automated running tasks).

Server configuration

Laravel has a few requirements for the server environment. However, these requirements can be achieved by using a home virtual machine, so it is highly recommended to use a home virtual machine as the local development environment.

If you do not use Homestead, you need to ensure that your server meets the following requirements. Here we take the long-term support version Laravel 5.5 as an example. If it is the latest version Laravel 5.8, you need PHP version >= 7.1.3:

  • PHP Version>= 7.0.0

  • OpenSSL PHP Extension

  • PDO PHP Extension

  • Mbstring PHP extension

  • Tokenizer PHP extension

  • XML PHP extension

Content covered by this Laravel5.8 tutorial manual

Laravel5.8 continues to be optimized on the basis of Laravel 5.7, including introducing new Eloquent relationships (has-one-through), optimizing email verification, based on Automatic registration of agreed authorization policy classes, DynamoDB cache and Session driver, optimized time zone configuration of task scheduler, support for assigning multiple authentication guards to broadcast channels, PSR-16 cache driver specification, etc.

Tips: Each chapter of this tutorial contains many Laravel examples. You can directly click the "Run Example" button to view the results online. These examples will help you better understand and use Laravel.