2

Laravel 9 LTS 将于 2022 一月份发布

 2 years ago
source link: https://zhuanlan.zhihu.com/p/414231093
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Laravel 9 LTS 将于 2022 一月份发布

摈弃世俗浮躁,追求技术精湛

转载自 Laravel 论坛:https://learnku.com/laravel/t/60868

Laravel v9 将成为 Laravel 的下一个 LTS 版本,并将在 2022 年初发布。在本篇文章中,我们想概述迄今为止宣布的所有新功能和更改。

Laravel 9 发布日期变更

Laravel v9 原定于今年 9 月左右发布,但 Laravel 团队决定将此版本推迟到 2022 年 1 月:

Laravel 使用了各种社区推动的扩展包以及 9 个 Symfony 组件来实现框架内的许多功能。 Symfony 6.0 将于今年 11 月发布。 出于这个原因,所以我们选择将 Laravel 9.0 的发布推迟到 2022 年 1 月。 通过推迟发布,我们可以将的底层 Symfony 组件升级到 Symfony 6.0,而不必等到 2022 年 9 月才能执行此升级。 此外,由于我们的年度发布总是在 Symfony 发布两个月后进行,因此这将为未来的发布做好准备。

这也将推动未来主要版本的发布,接下来的计划是:

  • Laravel 9:2022年1月
  • Laravel 10:2023年1月
  • Laravel 11:2024年1月

Laravel 9 中的最低版本是 PHP 8

因为 Laravel 9 需要 Symfony 6.0,并且它的最低要求是 PHP 8,这意味着 Laravel 9 将受到相同的限制。

匿名存根迁移

今年早些时候,Laravel 8.37 推出了一个新功能,称为 匿名迁移,它可以防止迁移类名冲突。

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('people', function (Blueprint $table) {
            $table->string('first_name')->nullable();
        });
    }
};

当 Laravel 9 启动时,上面代码将是运行php artisan make:migration时的默认值

新的查询构建器接口

多亏了 Chris Morrell,Laravel 9 将具有一个新的查询构建器接口,您可以在 合并的PR 中查看所有细节。

对于在 IDE 中依赖类型提示进行静态分析、重构或代码完成的开发人员来说,Query\BuilderEloquent\BuilderEloquent\Relation 之间缺乏共享接口或继承可能相当棘手:

return Model::query()
    ->whereNotExists(function($query) {
        // $query is a Query\Builder
    })
    ->whereHas('relation', function($query) {
        // $query is an Eloquent\Builder
    })
    ->with('relation', function($query) {
        // $query is an Eloquent\Relation
    });

此功能添加了一个新的 Illuminate\Contracts\Database\QueryBuilder 接口和一个 Illuminate\Database\Eloquent\Concerns\DecoratesQueryBuilder 特性,该特性实现了该接口来代替现有的 __call 实现。

PHP 8 字符串函数

由于 PHP 8 将是最低版本,Tom Schlick 提交了 PR 以转向使用 str_contains()str_starts_with()str_ends_with ()\Illuminate\Support\Str 类内部运行。

从 SwiftMailer 到 Symfony Mailer

Symfony 弃用了 SwiftMailer,而 Laravel 9 进行了更改,以将 Symfony Mailer 用于所有邮件传输。 这确实带来了一些重大更改,您可以 查看 PR 了解所有详细信息。 Laravel 9 升级指南将在正式发布后包含说明。

还有...

Laravel 9 还有几个月的时间,更多的新功能和公告将会发布。 我们将在发布时更新这篇文章。

讨论请前往专业的 Laravel 论坛:https://learnku.com/laravel/t/60868


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK