Hướng dẫn which php version is required for laravel 8? - phiên bản php nào được yêu cầu cho laravel 8?

Phiên bản

Show

Hướng dẫn which php version is required for laravel 8? - phiên bản php nào được yêu cầu cho laravel 8?

Cảnh báo bạn đang duyệt tài liệu cho một phiên bản cũ của Laravel. Xem xét nâng cấp dự án của bạn lên Laravel 9.x. You're browsing the documentation for an old version of Laravel. Consider upgrading your project to Laravel 9.x.

Hướng dẫn nâng cấp

  • Nâng cấp lên 8.0 từ 7.x

Thay đổi tác động cao

Thay đổi tác động trung bình

Nâng cấp lên 8.0 từ 7.x

Thời gian nâng cấp ước tính: 15 phút

{Lưu ý} Chúng tôi cố gắng ghi lại mọi thay đổi phá vỡ có thể. Vì một số thay đổi phá vỡ này nằm trong các phần tối nghĩa của khung, chỉ một phần của những thay đổi này thực sự có thể ảnh hưởng đến ứng dụng của bạn.

Php 7.3.0 yêu cầu

Khả năng tác động: Trung bình

Phiên bản PHP tối thiểu mới hiện là 7.3.0.

Cập nhật phụ thuộc

Cập nhật các phụ thuộc sau trong tệp

<?php

namespace Database\Seeders;

use App\Models\User;

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder

{

/**

* Seed the application's database.

*

* @return void

*/

public function run()

{

...

}

}

4 của bạn:

  • <?php

    namespace Database\Seeders;

    use App\Models\User;

    use Illuminate\Database\Seeder;

    class DatabaseSeeder extends Seeder

    {

    /**

    * Seed the application's database.

    *

    * @return void

    */

    public function run()

    {

    ...

    }

    }

    5 đến

    <?php

    namespace Database\Seeders;

    use App\Models\User;

    use Illuminate\Database\Seeder;

    class DatabaseSeeder extends Seeder

    {

    /**

    * Seed the application's database.

    *

    * @return void

    */

    public function run()

    {

    ...

    }

    }

    6
  • <?php

    namespace Database\Seeders;

    use App\Models\User;

    use Illuminate\Database\Seeder;

    class DatabaseSeeder extends Seeder

    {

    /**

    * Seed the application's database.

    *

    * @return void

    */

    public function run()

    {

    ...

    }

    }

    7 đến

    <?php

    namespace Database\Seeders;

    use App\Models\User;

    use Illuminate\Database\Seeder;

    class DatabaseSeeder extends Seeder

    {

    /**

    * Seed the application's database.

    *

    * @return void

    */

    public function run()

    {

    ...

    }

    }

    8
  • <?php

    namespace Database\Seeders;

    use App\Models\User;

    use Illuminate\Database\Seeder;

    class DatabaseSeeder extends Seeder

    {

    /**

    * Seed the application's database.

    *

    * @return void

    */

    public function run()

    {

    ...

    }

    }

    9 đến

    "autoload": {

    "psr-4": {

    "App\\": "app/",

    "Database\\Factories\\": "database/factories/",

    "Database\\Seeders\\": "database/seeders/"

    }

    },

    0
  • "autoload": {

    "psr-4": {

    "App\\": "app/",

    "Database\\Factories\\": "database/factories/",

    "Database\\Seeders\\": "database/seeders/"

    }

    },

    1 đến

    "autoload": {

    "psr-4": {

    "App\\": "app/",

    "Database\\Factories\\": "database/factories/",

    "Database\\Seeders\\": "database/seeders/"

    }

    },

    2
  • "autoload": {

    "psr-4": {

    "App\\": "app/",

    "Database\\Factories\\": "database/factories/",

    "Database\\Seeders\\": "database/seeders/"

    }

    },

    3 đến

    "autoload": {

    "psr-4": {

    "App\\": "app/",

    "Database\\Factories\\": "database/factories/",

    "Database\\Seeders\\": "database/seeders/"

    }

    },

    4
  • "autoload": {

    "psr-4": {

    "App\\": "app/",

    "Database\\Factories\\": "database/factories/",

    "Database\\Seeders\\": "database/seeders/"

    }

    },

    5 đến

    "autoload": {

    "psr-4": {

    "App\\": "app/",

    "Database\\Factories\\": "database/factories/",

    "Database\\Seeders\\": "database/seeders/"

    }

    },

    6

Các gói của bên đầu tiên sau đây có các bản phát hành chính mới để hỗ trợ Laravel 8. Nếu có, bạn nên đọc hướng dẫn nâng cấp cá nhân của họ trước khi nâng cấp:

Ngoài ra, trình cài đặt Laravel đã được cập nhật để hỗ trợ

"autoload": {

"psr-4": {

"App\\": "app/",

"Database\\Factories\\": "database/factories/",

"Database\\Seeders\\": "database/seeders/"

}

},

7 và Laravel JetStream. Bất kỳ trình cài đặt nào lớn hơn 4.0 sẽ ngừng hoạt động sau tháng 10 năm 2020. Bạn nên nâng cấp trình cài đặt toàn cầu của mình lên

"autoload": {

"psr-4": {

"App\\": "app/",

"Database\\Factories\\": "database/factories/",

"Database\\Seeders\\": "database/seeders/"

}

},

8 càng sớm càng tốt.

Cuối cùng, kiểm tra bất kỳ gói nào khác của bên thứ ba được tiêu thụ bởi ứng dụng của bạn và xác minh bạn đang sử dụng phiên bản thích hợp cho hỗ trợ của Laravel 8.

Bộ sưu tập

Phương pháp

"autoload": {

"psr-4": {

"App\\": "app/",

"Database\\Factories\\": "database/factories/",

"Database\\Seeders\\": "database/seeders/"

}

},

9

Khả năng tác động: Thấp

Để phù hợp với hành vi PHP điển hình, phương pháp

composer require laravel/legacy-factories

0 của

composer require laravel/legacy-factories

1 đã được cập nhật để sử dụng

"autoload": {

"psr-4": {

"App\\": "app/",

"Database\\Factories\\": "database/factories/",

"Database\\Seeders\\": "database/seeders/"

}

},

9 thay vì

composer require laravel/legacy-factories

3. Điều này có thể đưa ra một sự thay đổi trong hành vi khi xử lý các mục thu thập có giá trị

composer require laravel/legacy-factories

4:

$collection = collect([null]);

// Laravel 7.x - true

isset($collection[0]);

// Laravel 8.x - false

isset($collection[0]);

Cơ sở dữ liệu

SEETER & FACTORY NAMESPARE

Khả năng tác động: cao

Người gieo hạt và nhà máy hiện đang được đặt tên. Để phù hợp với những thay đổi này, hãy thêm không gian tên

composer require laravel/legacy-factories

5 vào các lớp Seeder của bạn. Ngoài ra, thư mục

composer require laravel/legacy-factories

6 trước đó phải được đổi tên thành

composer require laravel/legacy-factories

7:

<?php

namespace Database\Seeders;

use App\Models\User;

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder

{

/**

* Seed the application's database.

*

* @return void

*/

public function run()

{

...

}

}

Nếu bạn đang chọn sử dụng gói

composer require laravel/legacy-factories

8, không có thay đổi nào đối với các lớp nhà máy của bạn là bắt buộc. Tuy nhiên, nếu bạn đang nâng cấp các nhà máy của mình, bạn nên thêm không gian tên

composer require laravel/legacy-factories

9 cho các lớp đó.

Tiếp theo, trong tệp

<?php

namespace Database\Seeders;

use App\Models\User;

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder

{

/**

* Seed the application's database.

*

* @return void

*/

public function run()

{

...

}

}

4 của bạn, xóa khối

public static function castUsing(array $arguments);

1 khỏi phần

public static function castUsing(array $arguments);

2 và thêm ánh xạ thư mục lớp tên mới:

"autoload": {

"psr-4": {

"App\\": "app/",

"Database\\Factories\\": "database/factories/",

"Database\\Seeders\\": "database/seeders/"

}

},

Hùng hồn

Nhà máy mô hình

Khả năng tác động: cao

Người gieo hạt và nhà máy hiện đang được đặt tên. Để phù hợp với những thay đổi này, hãy thêm không gian tên

composer require laravel/legacy-factories

5 vào các lớp Seeder của bạn. Ngoài ra, thư mục

composer require laravel/legacy-factories

6 trước đó phải được đổi tên thành

composer require laravel/legacy-factories

7:

composer require laravel/legacy-factories

Nếu bạn đang chọn sử dụng gói

composer require laravel/legacy-factories

8, không có thay đổi nào đối với các lớp nhà máy của bạn là bắt buộc. Tuy nhiên, nếu bạn đang nâng cấp các nhà máy của mình, bạn nên thêm không gian tên

composer require laravel/legacy-factories

9 cho các lớp đó.

Khả năng tác động: Thấp

Để phù hợp với hành vi PHP điển hình, phương pháp

composer require laravel/legacy-factories

0 của

composer require laravel/legacy-factories

1 đã được cập nhật để sử dụng

"autoload": {

"psr-4": {

"App\\": "app/",

"Database\\Factories\\": "database/factories/",

"Database\\Seeders\\": "database/seeders/"

}

},

9 thay vì

composer require laravel/legacy-factories

3. Điều này có thể đưa ra một sự thay đổi trong hành vi khi xử lý các mục thu thập có giá trị

composer require laravel/legacy-factories

4:

public static function castUsing(array $arguments);

$collection = collect([null]);

// Laravel 7.x - true

isset($collection[0]);

// Laravel 8.x - false

isset($collection[0]);

Khả năng tác động: Thấp

Để phù hợp với hành vi PHP điển hình, phương pháp

composer require laravel/legacy-factories

0 của

composer require laravel/legacy-factories

1 đã được cập nhật để sử dụng

"autoload": {

"psr-4": {

"App\\": "app/",

"Database\\Factories\\": "database/factories/",

"Database\\Seeders\\": "database/seeders/"

}

},

9 thay vì

composer require laravel/legacy-factories

3. Điều này có thể đưa ra một sự thay đổi trong hành vi khi xử lý các mục thu thập có giá trị

composer require laravel/legacy-factories

4:

$collection = collect([null]);// Laravel 7.x - trueisset($collection[0]);// Laravel 8.x - falseisset($collection[0]);

Cơ sở dữ liệu

Khả năng tác động: Thấp

Để phù hợp với hành vi PHP điển hình, phương pháp

composer require laravel/legacy-factories

0 của

composer require laravel/legacy-factories

1 đã được cập nhật để sử dụng

"autoload": {

"psr-4": {

"App\\": "app/",

"Database\\Factories\\": "database/factories/",

"Database\\Seeders\\": "database/seeders/"

}

},

9 thay vì

composer require laravel/legacy-factories

3. Điều này có thể đưa ra một sự thay đổi trong hành vi khi xử lý các mục thu thập có giá trị

composer require laravel/legacy-factories

4:

$collection = collect([null]);

// Laravel 7.x - true

isset($collection[0]);

// Laravel 8.x - false

isset($collection[0]);

Khả năng tác động: Thấp

Để phù hợp với hành vi PHP điển hình, phương pháp

composer require laravel/legacy-factories

0 của

composer require laravel/legacy-factories

1 đã được cập nhật để sử dụng

"autoload": {

"psr-4": {

"App\\": "app/",

"Database\\Factories\\": "database/factories/",

"Database\\Seeders\\": "database/seeders/"

}

},

9 thay vì

composer require laravel/legacy-factories

3. Điều này có thể đưa ra một sự thay đổi trong hành vi khi xử lý các mục thu thập có giá trị

composer require laravel/legacy-factories

4:

public function listen($events, $listener = null);

$collection = collect([null]);// Laravel 7.x - trueisset($collection[0]);// Laravel 8.x - falseisset($collection[0]);

Cơ sở dữ liệu

SEETER & FACTORY NAMESPARE

Khả năng tác động: cao

define('LARAVEL_START', microtime(true));

if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {

require __DIR__.'/../storage/framework/maintenance.php';

}

Người gieo hạt và nhà máy hiện đang được đặt tên. Để phù hợp với những thay đổi này, hãy thêm không gian tên

composer require laravel/legacy-factories

5 vào các lớp Seeder của bạn. Ngoài ra, thư mục

composer require laravel/legacy-factories

6 trước đó phải được đổi tên thành

composer require laravel/legacy-factories

7:

Khả năng tác động: Trung bình

Phiên bản PHP tối thiểu mới hiện là 7.3.0.

Cập nhật phụ thuộc

Khả năng tác động: Thấp

Để phù hợp với hành vi PHP điển hình, phương pháp

composer require laravel/legacy-factories

0 của

composer require laravel/legacy-factories

1 đã được cập nhật để sử dụng

"autoload": {

"psr-4": {

"App\\": "app/",

"Database\\Factories\\": "database/factories/",

"Database\\Seeders\\": "database/seeders/"

}

},

9 thay vì

composer require laravel/legacy-factories

3. Điều này có thể đưa ra một sự thay đổi trong hành vi khi xử lý các mục thu thập có giá trị

composer require laravel/legacy-factories

4:

Quản lý tài sản

define('LARAVEL_START', microtime(true));

if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {

require __DIR__.'/../storage/framework/maintenance.php';

}

5

Khả năng tác động: Thấp

Thuộc tính

define('LARAVEL_START', microtime(true));

if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {

require __DIR__.'/../storage/framework/maintenance.php';

}

5 không dùng trước của lớp

define('LARAVEL_START', microtime(true));

if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {

require __DIR__.'/../storage/framework/maintenance.php';

}

7 đã bị xóa. Nếu bạn đang dựa vào tài sản này, bạn nên sử dụng thuộc tính

define('LARAVEL_START', microtime(true));

if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {

require __DIR__.'/../storage/framework/maintenance.php';

}

8 thay thế.

Người trợ giúp

define('LARAVEL_START', microtime(true));

if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {

require __DIR__.'/../storage/framework/maintenance.php';

}

9

Khả năng tác động: Thấp

Thuộc tính

define('LARAVEL_START', microtime(true));

if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {

require __DIR__.'/../storage/framework/maintenance.php';

}

5 không dùng trước của lớp

define('LARAVEL_START', microtime(true));

if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {

require __DIR__.'/../storage/framework/maintenance.php';

}

7 đã bị xóa. Nếu bạn đang dựa vào tài sản này, bạn nên sử dụng thuộc tính

define('LARAVEL_START', microtime(true));

if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {

require __DIR__.'/../storage/framework/maintenance.php';

}

8 thay thế.

Người trợ giúp define('LARAVEL_START', microtime(true));if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) { require __DIR__.'/../storage/framework/maintenance.php';}9

Trình trợ giúp

define('LARAVEL_START', microtime(true));

if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {

require __DIR__.'/../storage/framework/maintenance.php';

}

9 không dùng nữa đã bị loại bỏ. Các ứng dụng vẫn sử dụng phương pháp này được khuyến khích nâng cấp lên Laravel Mix.

Khả năng tác động: Thấp

Thuộc tính

define('LARAVEL_START', microtime(true));

if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {

require __DIR__.'/../storage/framework/maintenance.php';

}

5 không dùng trước của lớp

define('LARAVEL_START', microtime(true));

if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {

require __DIR__.'/../storage/framework/maintenance.php';

}

7 đã bị xóa. Nếu bạn đang dựa vào tài sản này, bạn nên sử dụng thuộc tính

define('LARAVEL_START', microtime(true));

if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {

require __DIR__.'/../storage/framework/maintenance.php';

}

8 thay thế.

Người trợ giúp define('LARAVEL_START', microtime(true));if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) { require __DIR__.'/../storage/framework/maintenance.php';}9

Trình trợ giúp

define('LARAVEL_START', microtime(true));

if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {

require __DIR__.'/../storage/framework/maintenance.php';

}

9 không dùng nữa đã bị loại bỏ. Các ứng dụng vẫn sử dụng phương pháp này được khuyến khích nâng cấp lên Laravel Mix.

Thư

Phương pháp

use Illuminate\Pagination\Paginator;

Paginator::useBootstrap();

1

use Illuminate\Pagination\Paginator;

Paginator::useBootstrap();

Phương pháp use Illuminate\Pagination\Paginator;Paginator::useBootstrap();1 không dùng trước đó đã bị loại bỏ. Thay vào đó, vui lòng sử dụng phương pháp use Illuminate\Pagination\Paginator;Paginator::useBootstrap();3.

Phân trang

Thư

Phương pháp

use Illuminate\Pagination\Paginator;

Paginator::useBootstrap();

1

Phương pháp

use Illuminate\Pagination\Paginator;

Paginator::useBootstrap();

1 không dùng trước đó đã bị loại bỏ. Thay vào đó, vui lòng sử dụng phương pháp

use Illuminate\Pagination\Paginator;

Paginator::useBootstrap();

3.

Thư

Phương pháp

use Illuminate\Pagination\Paginator;

Paginator::useBootstrap();

1

Phương pháp

use Illuminate\Pagination\Paginator;

Paginator::useBootstrap();

1 không dùng trước đó đã bị loại bỏ. Thay vào đó, vui lòng sử dụng phương pháp

use Illuminate\Pagination\Paginator;

Paginator::useBootstrap();

3.

Thư

Phương pháp

use Illuminate\Pagination\Paginator;

Paginator::useBootstrap();

1

ProcessPodcast::withChain([

new OptimizePodcast,

new ReleasePodcast

])->onConnection('redis')->onQueue('podcasts')->dispatch();

Phương pháp

use Illuminate\Pagination\Paginator;

Paginator::useBootstrap();

1 không dùng trước đó đã bị loại bỏ. Thay vào đó, vui lòng sử dụng phương pháp

use Illuminate\Pagination\Paginator;

Paginator::useBootstrap();

3.

Phân trang

Mặc định phân trang

Khả năng tác động: cao

use Illuminate\Database\Schema\Blueprint;

use Illuminate\Support\Facades\Schema;

Schema::table('failed_jobs', function (Blueprint $table) {

$table->string('uuid')->after('id')->nullable()->unique();

});

Paginator hiện sử dụng khung CSS Tailwind cho kiểu dáng mặc định của nó. Để tiếp tục sử dụng BootStrap, bạn nên thêm cuộc gọi phương thức sau vào phương thức

use Illuminate\Pagination\Paginator;

Paginator::useBootstrap();

4 của ứng dụng

use Illuminate\Pagination\Paginator;

Paginator::useBootstrap();

5:

Xếp hàng

Phương pháp

use Illuminate\Pagination\Paginator;

Paginator::useBootstrap();

6

Để thống nhất với các tính năng khác của Laravel, phương pháp use Illuminate\Pagination\Paginator;Paginator::useBootstrap();6 và tài sản use Illuminate\Pagination\Paginator;Paginator::useBootstrap();6 của các công việc xếp hàng, người gửi thư, thông báo và người nghe đã được đổi tên thành use Illuminate\Pagination\Paginator;Paginator::useBootstrap();9. Bạn nên cập nhật tên của phương thức / thuộc tính này trong các lớp có liên quan trong ứng dụng của bạn.

Tài sản

ProcessPodcast::withChain([

new OptimizePodcast,

new ReleasePodcast

])->onConnection('redis')->onQueue('podcasts')->dispatch();

0

Mặc định phân trang

Khả năng tác động: cao

Paginator hiện sử dụng khung CSS Tailwind cho kiểu dáng mặc định của nó. Để tiếp tục sử dụng BootStrap, bạn nên thêm cuộc gọi phương thức sau vào phương thức

use Illuminate\Pagination\Paginator;

Paginator::useBootstrap();

4 của ứng dụng

use Illuminate\Pagination\Paginator;

Paginator::useBootstrap();

5:

<?php

namespace Database\Seeders;

use App\Models\User;

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder

{

/**

* Seed the application's database.

*

* @return void

*/

public function run()

{

...

}

}

1

Xếp hàng

Phương pháp

use Illuminate\Pagination\Paginator;

Paginator::useBootstrap();

6

<?php

namespace Database\Seeders;

use App\Models\User;

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder

{

/**

* Seed the application's database.

*

* @return void

*/

public function run()

{

...

}

}

2

Để thống nhất với các tính năng khác của Laravel, phương pháp use Illuminate\Pagination\Paginator;Paginator::useBootstrap();6 và tài sản use Illuminate\Pagination\Paginator;Paginator::useBootstrap();6 của các công việc xếp hàng, người gửi thư, thông báo và người nghe đã được đổi tên thành use Illuminate\Pagination\Paginator;Paginator::useBootstrap();9. Bạn nên cập nhật tên của phương thức / thuộc tính này trong các lớp có liên quan trong ứng dụng của bạn.

Tài sản

ProcessPodcast::withChain([

new OptimizePodcast,

new ReleasePodcast

])->onConnection('redis')->onQueue('podcasts')->dispatch();

0

Khả năng tác động: Thấp

Tài sản

ProcessPodcast::withChain([

new OptimizePodcast,

new ReleasePodcast

])->onConnection('redis')->onQueue('podcasts')->dispatch();

0 của các công việc xếp hàng, thông báo và người nghe đã được đổi tên thành

ProcessPodcast::withChain([

new OptimizePodcast,

new ReleasePodcast

])->onConnection('redis')->onQueue('podcasts')->dispatch();

2. Bạn nên cập nhật tên của thuộc tính này trong các lớp có liên quan trong ứng dụng của bạn.

Phương pháp ProcessPodcast::withChain([ new OptimizePodcast, new ReleasePodcast])->onConnection('redis')->onQueue('podcasts')->dispatch();3 / ProcessPodcast::withChain([ new OptimizePodcast, new ReleasePodcast])->onConnection('redis')->onQueue('podcasts')->dispatch();4

Để thống nhất với các phương pháp điều phối khác, các phương pháp

ProcessPodcast::withChain([

new OptimizePodcast,

new ReleasePodcast

])->onConnection('redis')->onQueue('podcasts')->dispatch();

3 và

ProcessPodcast::withChain([

new OptimizePodcast,

new ReleasePodcast

])->onConnection('redis')->onQueue('podcasts')->dispatch();

4 được sử dụng với chuỗi công việc đã được loại bỏ. Thay vào đó, bạn có thể sử dụng các phương thức

ProcessPodcast::withChain([

new OptimizePodcast,

new ReleasePodcast

])->onConnection('redis')->onQueue('podcasts')->dispatch();

7 và

ProcessPodcast::withChain([

new OptimizePodcast,

new ReleasePodcast

])->onConnection('redis')->onQueue('podcasts')->dispatch();

8. Các phương thức này nên được gọi trước khi gọi phương thức

ProcessPodcast::withChain([

new OptimizePodcast,

new ReleasePodcast

])->onConnection('redis')->onQueue('podcasts')->dispatch();

9:

Khả năng tác động: Thấp

Lưu ý rằng thay đổi này chỉ ảnh hưởng đến mã bằng phương pháp

use Illuminate\Database\Schema\Blueprint;

use Illuminate\Support\Facades\Schema;

Schema::table('failed_jobs', function (Blueprint $table) {

$table->string('uuid')->after('id')->nullable()->unique();

});

0.

ProcessPodcast::withChain([

new OptimizePodcast,

new ReleasePodcast

])->onConnection('redis')->onQueue('podcasts')->dispatch();

3 và

ProcessPodcast::withChain([

new OptimizePodcast,

new ReleasePodcast

])->onConnection('redis')->onQueue('podcasts')->dispatch();

4 vẫn có sẵn khi sử dụng Trình trợ giúp toàn cầu ____993.

<?php

namespace Database\Seeders;

use App\Models\User;

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder

{

/**

* Seed the application's database.

*

* @return void

*/

public function run()

{

...

}

}

3

Hỗ trợ hàng loạt công việc không thành công

Khả năng tác động: Tùy chọn

Khả năng tác động: Thấp

Nếu bạn có kế hoạch sử dụng các tính năng hàng loạt công việc của Laravel 8.x, bảng cơ sở dữ liệu

use Illuminate\Database\Schema\Blueprint;

use Illuminate\Support\Facades\Schema;

Schema::table('failed_jobs', function (Blueprint $table) {

$table->string('uuid')->after('id')->nullable()->unique();

});

4 của bạn sẽ cần được cập nhật. Đầu tiên, một cột

use Illuminate\Database\Schema\Blueprint;

use Illuminate\Support\Facades\Schema;

Schema::table('failed_jobs', function (Blueprint $table) {

$table->string('uuid')->after('id')->nullable()->unique();

});

5 mới nên được thêm vào bảng của bạn:

Tiếp theo, tùy chọn cấu hình

use Illuminate\Database\Schema\Blueprint;

use Illuminate\Support\Facades\Schema;

Schema::table('failed_jobs', function (Blueprint $table) {

$table->string('uuid')->after('id')->nullable()->unique();

});

6 trong tệp cấu hình

use Illuminate\Database\Schema\Blueprint;

use Illuminate\Support\Facades\Schema;

Schema::table('failed_jobs', function (Blueprint $table) {

$table->string('uuid')->after('id')->nullable()->unique();

});

7 của bạn sẽ được cập nhật lên

use Illuminate\Database\Schema\Blueprint;

use Illuminate\Support\Facades\Schema;

Schema::table('failed_jobs', function (Blueprint $table) {

$table->string('uuid')->after('id')->nullable()->unique();

});

8.

Ngoài ra, bạn có thể muốn tạo UUID cho các công việc thất bại hiện tại của mình:

<?php

namespace Database\Seeders;

use App\Models\User;

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder

{

/**

* Seed the application's database.

*

* @return void

*/

public function run()

{

...

}

}

0

Thẩm định

Kết nối quy tắc cơ sở dữ liệu

Khả năng tác động: Thấp

Các quy tắc

<?php

namespace Database\Seeders;

use App\Models\User;

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder

{

/**

* Seed the application's database.

*

* @return void

*/

public function run()

{

...

}

}

25 và

<?php

namespace Database\Seeders;

use App\Models\User;

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder

{

/**

* Seed the application's database.

*

* @return void

*/

public function run()

{

...

}

}

26 hiện sẽ tôn trọng tên kết nối được chỉ định (được truy cập qua phương thức

<?php

namespace Database\Seeders;

use App\Models\User;

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder

{

/**

* Seed the application's database.

*

* @return void

*/

public function run()

{

...

}

}

27 của mô hình) của các mô hình hùng biện khi thực hiện các truy vấn.

Điều khoản khác

Chúng tôi cũng khuyến khích bạn xem các thay đổi trong kho

<?php

namespace Database\Seeders;

use App\Models\User;

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder

{

/**

* Seed the application's database.

*

* @return void

*/

public function run()

{

...

}

}

28 GitHub. Mặc dù không cần nhiều thay đổi trong số này, bạn có thể muốn giữ các tệp này đồng bộ với ứng dụng của mình. Một số thay đổi này sẽ được đề cập trong hướng dẫn nâng cấp này, nhưng những thay đổi khác, chẳng hạn như thay đổi đối với các tệp cấu hình hoặc nhận xét, sẽ không được. Bạn có thể dễ dàng xem các thay đổi với công cụ so sánh GitHub và chọn cập nhật nào quan trọng đối với bạn.

Laravel đã sẵn sàng cho PHP 8 chưa?

Laravel hiện yêu cầu PHP 8.0.2 trở lên..

Liệu Laravel 9 có yêu cầu Php 8 không?

Yêu cầu PHP tối thiểu đầu tiên và quan trọng nhất, Laravel 9 yêu cầu PHP 8 và PHPUNIT 8 mới nhất để thử nghiệm.Đó là bởi vì Laravel 9 sẽ sử dụng Symfony V6 mới nhất.0, cũng yêu cầu PHP 8.Laravel 9 requires the latest PHP 8 and PHPUnit 8 for testing. That's because Laravel 9 will be using the newest Symfony v6. 0, which also requires PHP 8.

Phiên bản PHP nào là tốt nhất cho Laravel?

Php 8.0 là nhà vô địch không thể tranh cãi với Laravel, trong khi Php 8.1 đến cuối cùng. is the undisputed champion with Laravel, while PHP 8.1 came in last.

Phiên bản mới nhất của Laravel 8 là gì?

Laravel 8 đã được phát hành vào ngày 8 tháng 9 năm 2020, với các tính năng mới như Laravel Jetstream, các lớp nhà máy mô hình, đè bẹp di cư, CSS Tailwind cho các quan điểm phân trang và các cải tiến khả năng sử dụng khác.Phiên bản Laravel mới nhất là phiên bản 9, được phát hành vào ngày 8 tháng 2 năm 2022.version 9, which was released on February 8, 2022.