This is the 7th day of my participation in the August Text Challenge.More challenges in August

Before, I wrote an article about Laravel improving the efficiency of DB query. After forwarding it to the group, some people questioned me and said, “Laravel is the framework he used several years ago, I didn’t expect that there are still people using it now.”

Nani, what do you mean? Don’t forget PHP is the best language!

Personally, Laravel is a very elegant development framework: elegant design patterns, powerful feature implementations, easy extensions, constant release updates, and most importantly, the best technology development community to date, in my opinion.

I have to make a Call for Laravel.

Laravel released version 8.0 on September 8, 2020. Laravel is scheduled to release version 9.0 on January 25, 2022.

Here I would like to introduce the new features of the latest Laravel release (8.0) :

Laravel 8 with the introduction of Laravel Jetstream, model factory classes, Migration compression, queue batching, improved rate limiting, queue improvements, dynamic Blade components, Tailwind paging view, Time test Assistant, artisan Serve improvements, Improvements to the event listener, along with various other bug fixes and usability improvements, continue to improve Laravel 7.x.

PHP is the best language and Laravel is the most elegant framework.

The installation of the Laravel

Server Requirements

The Laravel framework has some requirements for the system. All of these requirements can be met by the Laravel Homestead VIRTUAL machine, so it is highly recommended that you use Homestead as your local Laravel development environment. Of course, if you don’t use Homestead, make sure your server meets the following requirements:

  • PHP > = 7.3
  • BCMath PHP expand
  • Ctype PHP expand
  • The Fileinfo PHP expand
  • JSON PHP expand
  • Mbstring PHP expand
  • OpenSSL PHP expand
  • The PDO PHP expand
  • The Tokenizer PHP expand
  • XML PHP expand

Install Laravel

First, install the Laravel installer using Composer:

composer global require laravel/installer
Copy the code

Be sure to place the global Vendor bin directory of Composer in your system environment variable $PATH so that the system can find the Laravel executable. The path of this directory is different in different operating systems. Here are some common locations:

  • macOS: $HOME/.composer/vendor/bin
  • Windows: %USERPROFILE%\AppData\Roaming\Composer\vendor\binGNU /
  • Linux distributions:$HOME/.config/composer/vendor/binor$HOME/.composer/vendor/bin

You can also find and view the global installation path of Composer by running the Composer global About command. Once installed, the Laravel new command creates a brand new Laravel project in the directory you specify. For example, Laravel New Blog will create a directory named Blog with all of Laravel’s dependencies installed:

laravel new blog
Copy the code

Create projects by Composer

Alternatively, you can install Laravel by running create-project from a terminal:

composer create-project --prefer-dist laravel/laravel blog
Copy the code

Local development environment

If you have PHP installed locally and you want to use PHP’s built-in server to serve your application, use the Artisan command serve. This command launches the development server at http://localhost:8000:

php artisan serve
Copy the code

You can also get more local development through Homestead and Valet.

configuration

Public directory

After installing Laravel, you must point the Web server root to the public directory. The index.php file in this directory will act as the front-end controller for all HTTP requests coming into the application.

The configuration file

All configuration files for the Laravel framework are placed in the Config directory. Each option is annotated, making it easy to review the file and familiarize yourself with the available options.

The directory permissions

After installing Laravel, you may need to assign read and write permissions to these two files: the storage directory and the bootstrap/cache directory should allow the Web server to write to them, otherwise the Laravel program will not run. If you are using a Homestead virtual machine, these permissions are already configured for you.

Application of key

With Laravel installed, the next thing you should do is set your application’s key to a random string. If you are installing Laravel through Composer or the Laravel installer, this key has already been set up for you through the PHP artisan key:generate command. Normally, this string should be 32 characters long. The key can be set in the.env environment configuration file. If you have already renamed the.env.example file to.env. If the app key is not set, your user sessions and other encrypted data are no longer secure!

Other configuration

Beyond that, Laravel requires little extra configuration. You can start development anytime! However, if possible, you are expected to look at the config/app.php file and its comments. It contains several options that you may want to change depending on your application, such as Timezone and locale.

Web Server Configuration

Directory configuration

Laravel should always be used outside the root of the “Web directory” configured for your Web server. You should not attempt to use the Laravel application in a subdirectory of the Web Directory. Attempting to do so may expose sensitive files that exist in your application.

Elegant link

Apache

Laravel contains a public/.htaccess file that is usually used to hide the front-end controller of index.php from the resource path. Before serving Laravel with Apache, be sure to enable the mod_rewrite module so that the.htaccess file can be parsed by the server. If the.htaccess file that comes with Laravel doesn’t work, try the following instead:

Options +FollowSymLinks -Indexes RewriteEngine On RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteCond %{REQUEST_FILENAME} ! -d RewriteCond %{REQUEST_FILENAME} ! -f RewriteRule ^ index.php [L]Copy the code

Nginx

If you use Nginx, add the following configuration to your site configuration and all requests will be directed to the index.php front-end controller:

location / { try_files $uri $uri/ /index.php? $query_string; }Copy the code

Elegant links will be configured automatically when you use Homestead or Valet.

Gorgeous dividing line

For more on Laravel, check out my column: Server Development from Beginner to Master

Recommended reading

  1. I’m still working on Laravel? Don’t forget PHP is the best language. (1) How does Laravel elegantly set global variables

  2. I’m still working on Laravel? Don’t forget PHP is the best language. (2) Laravel Jetstream and model Factory classes

  3. I’m still working on Laravel? Don’t forget PHP is the best language. (3) Migration compression, queue batch processing, improve rate limit

  4. I’m still working on Laravel? Don’t forget PHP is the best language. (4) Optimization of maintenance mode

  5. # Is there any question that I’m still developing with Laravel? Don’t forget PHP is the best language. (5) Dynamic Blade event listener optimizes event test assistant

  6. I’m still working on Laravel? Don’t forget PHP is the best language. (6)

Last but not least

Technical group please come here. Or add my wechat account wangzhongyang0601 to learn together.