theme | background | class | highlighter | lineNumbers | info | drawings | layout | logoHeader | website | handle | introImage | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
unicorn |
text-center |
shiki |
false |
## Slidev Starter Template
Presentation slides for developers.
Learn more at [Sli.dev](https://sli.dev)
|
|
intro |
./images/techtrain.jpg |
suguru_ohki |
- PHP 8.0 が最低限必要
- Symfony6系を利用している
次のLTSとなるなりませんでしたw
version | release date |
---|---|
Laravel 9.0 | 2022年2月(February 2022) |
Laravel 10.0 | 2023年2月(February 2023) |
Laravel 11.0 | 2024年2月(February 2024) |
Anonymous Migration | Migration自体にそれぞれ名前をつける必要ない |
New Query Builder Interface | 「Query\Builder」「Eloquent\Builder」「Eloquent\Relation」の勘違いを減らす |
PHP 8 String Functions | \Illuminate\Support\Strクラスの内部でのstr_contains() 、 str_starts_with() 、およびstr_ends_with()のphpの標準関数の利用が始まる |
From SwiftMailer to Symfony Mailer | SymfonyがSwiftMailerを非推奨になったため、その解消 |
そもそもMigration自体にそれぞれ名前をつける必要があるんだっけ?という疑問から生まれた機能。
該当Issueはこちらで参考の書き方は次のとおり。
<?php
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();
});
}
};
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddColumnFirstNameInPeopleTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('people', function (Blueprint $table) {
$table->string('first_name')->nullable();
});
}
};
<?php
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();
});
}
};
クエリビルダインターフェースが提供されるようになる。これにより補完周りがかなり便利に。 こちら のプルリクエストにもあるように、補完が効いているときに、「Query\Builder」なのか「Eloquent\Builder」なのか「Eloquent\Relation」なのかによって補完が間違っているせいで一度エラーが出たなんて経験がある程度補完を使ったことがある人なら誰しもあるはず。そのエラーが出なくなるらしい。
<?php
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\Support\Strクラスの内部での
- str_contains()
- str_starts_with()
- str_ends_with()
のphpの標準関数の利用が始まる。今までphpの標準関数に文字列の中に特定nの文字が含まれるのかなどといった関数がなかったため、Laravelでは、独自のラッパーメソッドを実装していた。今回でその独自実装でなくなり、標準関数の利用が始まる
プルリクエストは こちら
Since PHP 8 will be the minimum, Tom Schlick submitted a PR to move to using str_contains(), str_starts_with() and str_ends_with() functions internally in the \Illuminate\Support\Str class.
プルリクエストはこちら
SymfonyがSwiftMailerを非推奨としたため、Laravel9で、すべてのメールトランスポートにSymfonyMailerを使用するように変更された
Symfony deprecated SwiftMailer and Laravel 9 makes the change to use Symfony Mailer for all the mail transports. This does open up a few breaking changes and you can review the PR for all the details. The Laravel 9 upgrade guide will include instructions once it's officially released.
php artisan test --coverage
- Laravel8での変更が鬼門となりそう
- モデルファクトリが8からクラスベースの書き方に変更があった。
- しばらくは一旦ヘルパーで捌けるとはいえ、長期的なことを考えると、書き換えておいた方が良さそう
<?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use App\Models\User;
use Faker\Generator as Faker;
use Illuminate\Support\Str;
$factory->define(User::class, function (Faker $faker) {
return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
];
});
use Illuminate\Database\Eloquent\Factories\Factory;
class UserFactory extends Factory
{
protected $model = User::class;
public function definition()
{
return [
'name' => $this->faker->name,
'email' => $this->faker->unique()->safeEmail,
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
];
}
}
- HasFactoryのtraitをModelに入れる必要がある
- ファクトリにネームスペースが付くため、ネームスペースをcomposer.jsonに追加
composer.jsonの修正
"fideloper/proxy"
こちらは削除します。
protected $headers = Request::HEADER_X_FORWARDED_ALL;
// ↓のようにアップデートする
protected $headers =
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO |
Request::HEADER_X_FORWARDED_AWS_ELB;
- phpstan(larastan)
- phpunit
- php-cs-fixer
- paratest
- laravel-ide-helper
- composer
https://github.com/rectorphp/rector
layout: center class: text-center