Prep Laravel v12 (#9495)

This commit is contained in:
Dries Vints 2024-03-13 17:01:21 +01:00 committed by GitHub
parent 474701c4fa
commit f908fe3b6d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 864 deletions

View File

@ -2,7 +2,7 @@
- [Versioning Scheme](#versioning-scheme)
- [Support Policy](#support-policy)
- [Laravel 11](#laravel-11)
- [Laravel 12](#laravel-12)
<a name="versioning-scheme"></a>
## Versioning Scheme
@ -46,322 +46,7 @@ For all Laravel releases, bug fixes are provided for 18 months and security fixe
(*) Supported PHP versions
<a name="laravel-11"></a>
## Laravel 11
<a name="laravel-12"></a>
## Laravel 12
Laravel 11 continues the improvements made in Laravel 10.x by introducing a streamlined application structure, per-second rate limiting, health routing, graceful encryption key rotation, queue testing improvements, [Resend](https://resend.com) mail transport, Prompt validator integration, new Artisan commands, and more. In addition, Laravel Reverb, a first-party, scalable WebSocket server has been introduced to provide robust real-time capabilities to your applications.
<a name="php-8"></a>
### PHP 8.2
Laravel 11.x requires a minimum PHP version of 8.2.
<a name="structure"></a>
### Streamlined Application Structure
_Laravel's streamlined application structure was developed by [Taylor Otwell](https://github.com/taylorotwell) and [Nuno Maduro](https://github.com/nunomaduro)_.
Laravel 11 introduces a streamlined application structure for **new** Laravel applications, without requiring any changes to existing applications. The new application structure is intended to provide a leaner, more modern experience, while retaining many of the concepts that Laravel developers are already familiar with. Below we will discuss the highlights of Laravel's new application structure.
#### The Application Bootstrap File
The `bootstrap/app.php` file has been revitalized as a code-first application configuration file. From this file, you may now customize your application's routing, middleware, service providers, exception handling, and more. This file unifies a variety of high-level application behavior settings that were previously scattered throughout your application's file structure:
```php
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware) {
//
})
->withExceptions(function (Exceptions $exceptions) {
//
})->create();
```
<a name="service-providers"></a>
#### Service Providers
Instead of the default Laravel application structure containing five service providers, Laravel 11 only includes a single `AppServiceProvider`. The functionality of the previous service providers has been incorporated into the `bootstrap/app.php`, is handled automatically by the framework, or may be placed in your application's `AppServiceProvider`.
For example, event discovery is now enabled by default, largely eliminating the need for manual registration of events and their listeners. However, if you do need to manually register events, you may simply do so in the `AppServiceProvider`. Similarly, route model bindings or authorization gates you may have previously registered in the `AuthServiceProvider` may also be registered in the `AppServiceProvider`.
<a name="opt-in-routing"></a>
#### Opt-in API and Broadcast Routing
The `api.php` and `channels.php` route files are no longer present by default, as many applications do not require these files. Instead, they may be created using simple Artisan commands:
```shell
php artisan install:api
php artisan install:broadcasting
```
<a name="middleware"></a>
#### Middleware
Previously, new Laravel applications included nine middleware. These middleware performed a variety of tasks such as authenticating requests, trimming input strings, and validating CSRF tokens.
In Laravel 11, these middleware have been moved into the framework itself, so that they do not add bulk to your application's structure. New methods for customizing the behavior of these middleware have been added to the framework and may be invoked from your application's `bootstrap/app.php` file:
```php
->withMiddleware(function (Middleware $middleware) {
$middleware->validateCsrfTokens(
except: ['stripe/*']
);
$middleware->web(append: [
EnsureUserIsSubscribed::class,
])
})
```
Since all middleware can be easily customized via your application's `bootstrap/app.php`, the need for a separate HTTP "kernel" class has been eliminated.
<a name="scheduling"></a>
#### Scheduling
Using a new `Schedule` facade, scheduled tasks may now be defined directly in your application's `routes/console.php` file, eliminating the need for a separate console "kernel" class:
```php
use Illuminate\Support\Facades\Schedule;
Schedule::command('emails:send')->daily();
```
<a name="exception-handling"></a>
#### Exception Handling
Like routing and middleware, exception handling can now be customized from your application's `bootstrap/app.php` file instead of a separate exception handler class, reducing the overall number of files included in a new Laravel application:
```php
->withExceptions(function (Exceptions $exceptions) {
$exceptions->dontReport(MissedFlightException::class);
$exceptions->report(function (InvalidOrderException $e) {
// ...
});
})
```
<a name="base-controller-class"></a>
#### Base `Controller` Class
The base controller included in new Laravel applications has been simplified. It no longer extends Laravel's internal `Controller` class, and the `AuthorizesRequests` and `ValidatesRequests` traits have been removed, as they may be included in your application's individual controllers if desired:
<?php
namespace App\Http\Controllers;
abstract class Controller
{
//
}
<a name="application-defaults"></a>
#### Application Defaults
By default, new Laravel applications use SQLite for database storage, as well as the `database` driver for Laravel's session, cache, and queue. This allows you to begin building your application immediately after creating a new Laravel application, without being required to install additional software or create additional database migrations.
In addition, over time, the `database` drivers for these Laravel services have become robust enough for production usage in many application contexts; therefore, they provide a sensible, unified choice for both local and production applications.
<a name="reverb"></a>
### Laravel Reverb
_Laravel Reverb was developed by [Joe Dixon](https://github.com/joedixon)_.
[Laravel Reverb](https://reverb.laravel.com) brings blazing-fast and scalable real-time WebSocket communication directly to your Laravel application, and provides seamless integration with Laravels existing suite of event broadcasting tools, such as Laravel Echo.
```shell
php artisan reverb:start
```
In addition, Reverb supports horizontal scaling via Redis's publish / subscribe capabilities, allowing you to distribute your WebSocket traffic across multiple backend Reverb servers all supporting a single, high-demand application.
For more information on Laravel Reverb, please consult the complete [Reverb documentation](/docs/{{version}}/reverb).
<a name="rate-limiting"></a>
### Per-Second Rate Limiting
_Per-second rate limiting was contributed by [Tim MacDonald](https://github.com/timacdonald)_.
Laravel now supports "per-second" rate limiting for all rate limiters, including those for HTTP requests and queued jobs. Previously, Laravel's rate limiters were limited to "per-minute" granularity:
```php
RateLimiter::for('invoices', function (Request $request) {
return Limit::perSecond(1);
});
```
For more information on rate limiting in Laravel, check out the [rate limiting documentation](/docs/{{version}}/routing#rate-limiting).
<a name="health"></a>
### Health Routing
_Health routing was contributed by [Taylor Otwell](https://github.com/taylorotwell)_.
New Laravel 11 applications include a `health` routing directive, which instructs Laravel to define a simple health-check endpoint that may be invoked by third-party application health monitoring services or orchestration systems like Kubernetes. By default, this route is served at `/up`:
```php
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
```
When HTTP requests are made to this route, Laravel will also dispatch a `DiagnosingHealth` event, allowing you to perform additional health checks that are relevant to your application.
<a name="encryption"></a>
### Graceful Encryption Key Rotation
_Graceful encryption key rotation was contributed by [Taylor Otwell](https://github.com/taylorotwell)_.
Since Laravel encrypts all cookies, including your application's session cookie, essentially every request to a Laravel application relies on encryption. However, because of this, rotating your application's encryption key would log all users out of your application. In addition, decrypting data that was encrypted by the previous encryption key becomes impossible.
Laravel 11 allows you to define your application's previous encryption keys as a comma-delimited list via the `APP_PREVIOUS_KEYS` environment variable.
When encrypting values, Laravel will always use the "current" encryption key, which is within the `APP_KEY` environment variable. When decrypting values, Laravel will first try the current key. If decryption fails using the current key, Laravel will try all previous keys until one of the keys is able to decrypt the value.
This approach to graceful decryption allows users to keep using your application uninterrupted even if your encryption key is rotated.
For more information on encryption in Laravel, check out the [encryption documentation](/docs/{{version}}/encryption).
<a name="prompt-validation"></a>
### Prompt Validation
_Prompt validator integration was contributed by [Andrea Marco Sartori](https://github.com/cerbero90)_.
[Laravel Prompts](/docs/{{version}}/prompts) is a PHP package for adding beautiful and user-friendly forms to your command-line applications, with browser-like features including placeholder text and validation.
Laravel Prompts supports input validation via closures:
```php
$name = text(
label: 'What is your name?',
validate: fn (string $value) => match (true) {
strlen($value) < 3 => 'The name must be at least 3 characters.',
strlen($value) > 255 => 'The name must not exceed 255 characters.',
default => null
}
);
```
However, this can become cumbersome when dealing with many inputs or complicated validation scenarios. Therefore, in Laravel 11, you may utilize the full power of Laravel's [validator](/docs/{{version}}/validation) when validating prompt inputs:
```php
$name = text('What is your name?', validate: [
'name' => 'required|min:3|max:255',
]);
```
<a name="queue-interaction-testing"></a>
### Queue Interaction Testing
_Queue interaction testing was contributed by [Taylor Otwell](https://github.com/taylorotwell)_.
Previously, attempting to test that a queued job was released, deleted, or manually failed was cumbersome and required the definition of custom queue fakes and stubs. However, in Laravel 11, you may easily test for these queue interactions using the `withFakeQueueInteractions` method:
```php
use App\Jobs\ProcessPodcast;
$job = (new ProcessPodcast)->withFakeQueueInteractions();
$job->handle();
$job->assertReleased(delay: 30);
```
For more information on testing queued jobs, check out the [queue documentation](/docs/{{version}}/queues#testing).
<a name="new-artisan-commands"></a>
### New Artisan Commands
_Class creation Artisan commands were contributed by [Taylor Otwell](https://github.com/taylorotwell)_.
New Artisan commands have been added to allow the quick creation of classes, enums, interfaces, and traits:
```shell
php artisan make:class
php artisan make:enum
php artisan make:interface
php artisan make:trait
```
<a name="model-cast-improvements"></a>
### Model Casts Improvements
_Model casts improvements were contributed by [Nuno Maduro](https://github.com/nunomaduro)_.
Laravel 11 supports defining your model's casts using a method instead of a property. This allows for streamlined, fluent cast definitions, especially when using casts with arguments:
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'options' => AsCollection::using(OptionCollection::class),
// AsEncryptedCollection::using(OptionCollection::class),
// AsEnumArrayObject::using(OptionEnum::class),
// AsEnumCollection::using(OptionEnum::class),
];
}
For more information on attribute casting, review the [Eloquent documentation](/docs/{{version}}/eloquent-mutators#attribute-casting).
<a name="the-once-function"></a>
### The `once` Function
_The `once` helper was contributed by [Taylor Otwell](https://github.com/taylorotwell)_ and _[Nuno Maduro](https://github.com/nunomaduro)_.
The `once` helper function executes the given callback and caches the result in memory for the duration of the request. Any subsequent calls to the `once` function with the same callback will return the previously cached result:
function random(): int
{
return once(function () {
return random_int(1, 1000);
});
}
random(); // 123
random(); // 123 (cached result)
random(); // 123 (cached result)
For more information on the `once` helper, check out the [helpers documentation](/docs/{{version}}/helpers#method-once).
<a name="database-performance"></a>
### Improved Performance When Testing With In-Memory Databases
_Improved in-memory database testing performance was contributed by [Anders Jenbo](https://github.com/AJenbo)_
Laravel 11 offers a significant speed boost when using the `:memory:` SQLite database during testing. To accomplish this, Laravel now maintains a reference to PHP's PDO object and reuses it across connections, often cutting total test run time in half.
<a name="mariadb"></a>
### Improved Support for MariaDB
_Improved support for MariaDB was contributed by [Jonas Staudenmeir](https://github.com/staudenmeir) and [Julius Kiekbusch](https://github.com/Jubeki)_
Laravel 11 includes improved support for MariaDB. In previous Laravel releases, you could use MariaDB via Laravel's MySQL driver. However, Laravel 11 now includes a dedicated MariaDB driver which provides better defaults for this database system.
For more information on Laravel's database drivers, check out the [database documentation](/docs/{{version}}/database).
<a name="inspecting-database"></a>
### Inspecting Databases and Improved Schema Operations
_Improved schema operations and database inspection was contributed by [Hafez Divandari](https://github.com/hafezdivandari)_
Laravel 11 provides additional database schema operation and inspection methods, including the native modifying, renaming, and dropping of columns. Furthermore, advanced spatial types, non-default schema names, and native schema methods for manipulating tables, views, columns, indexes, and foreign keys are provided:
use Illuminate\Support\Facades\Schema;
$tables = Schema::getTables();
$views = Schema::getViews();
$columns = Schema::getColumns('users');
$indexes = Schema::getIndexes('users');
$foreignKeys = Schema::getForeignKeys('users');
TBA...

View File

@ -1,18 +1,13 @@
# Upgrade Guide
- [Upgrading To 11.0 From 10.x](#upgrade-11.0)
- [Upgrading To 12.0 From 11.x](#upgrade-12.0)
<a name="high-impact-changes"></a>
## High Impact Changes
<div class="content-list" markdown="1">
- [Updating Dependencies](#updating-dependencies)
- [Application Structure](#application-structure)
- [Floating-Point Types](#floating-point-types)
- [Modifying Columns](#modifying-columns)
- [SQLite Minimum Version](#sqlite-minimum-version)
- [Updating Sanctum](#updating-sanctum)
- TBD
</div>
@ -21,9 +16,7 @@
<div class="content-list" markdown="1">
- [Carbon 3](#carbon-3)
- [Password Rehashing](#password-rehashing)
- [Per-Second Rate Limiting](#per-second-rate-limiting)
- TBD
</div>
@ -32,21 +25,15 @@
<div class="content-list" markdown="1">
- [Doctrine DBAL Removal](#doctrine-dbal-removal)
- [Eloquent Model `casts` Method](#eloquent-model-casts-method)
- [Spatial Types](#spatial-types)
- [Spatie Once Package](#spatie-once-package)
- [The `Enumerable` Contract](#the-enumerable-contract)
- [The `UserProvider` Contract](#the-user-provider-contract)
- [The `Authenticatable` Contract](#the-authenticatable-contract)
- TBD
</div>
<a name="upgrade-11.0"></a>
## Upgrading To 11.0 From 10.x
<a name="upgrade-12.0"></a>
## Upgrading To 12.0 From 11.x
<a name="estimated-upgrade-time-??-minutes"></a>
#### Estimated Upgrade Time: 15 Minutes
#### Estimated Upgrade Time: ?? Minutes
> [!NOTE]
> We attempt to document every possible breaking change. Since some of these breaking changes are in obscure parts of the framework only a portion of these changes may actually affect your application. Want to save time? You can use [Laravel Shift](https://laravelshift.com/) to help automate your application upgrades.
@ -56,540 +43,17 @@
**Likelihood Of Impact: High**
#### PHP 8.2.0 Required
Laravel now requires PHP 8.2.0 or greater.
#### Composer Dependencies
You should update the following dependencies in your application's `composer.json` file:
<div class="content-list" markdown="1">
- `laravel/framework` to `^11.0`
- `nunomaduro/collision` to `^8.1`
- `laravel/breeze` to `^2.0` (If installed)
- `laravel/cashier` to `^15.0` (If installed)
- `laravel/dusk` to `^8.0` (If installed)
- `laravel/jetstream` to `^5.0` (If installed)
- `laravel/passport` to `^12.0` (If installed)
- `laravel/sanctum` to `^4.0` (If installed)
- `laravel/spark-stripe` to `^5.0` (If installed)
- `laravel/telescope` to `^5.0` (If installed)
- `inertiajs/inertia-laravel` to `^1.0` (If installed)
- `laravel/framework` to `^12.0`
</div>
If your application is using Laravel Cashier Stripe, Passport, Sanctum, Spark Stripe, or Telescope, you will need to publish their migrations to your application. Cashier Stripe, Passport, Sanctum, Spark Stripe, and Telescope **no longer automatically load migrations from their own migrations** directory. Therefore, you should run the following command to publish their migrations to your application:
```bash
php artisan vendor:publish --tag=cashier-migrations
php artisan vendor:publish --tag=passport-migrations
php artisan vendor:publish --tag=sanctum-migrations
php artisan vendor:publish --tag=spark-migrations
php artisan vendor:publish --tag=telescope-migrations
```
In addition, you should review the upgrade guides for each of these packages to ensure you are aware of any additional breaking changes:
- [Laravel Cashier Stripe](#cashier-stripe)
- [Laravel Passport](#passport)
- [Laravel Sanctum](#sanctum)
- [Laravel Spark Stripe](#spark-stripe)
- [Laravel Telescope](#telescope)
If you have manually installed the Laravel installer, you should update the installer via Composer:
```bash
composer global require laravel/installer:^5.6
```
Finally, you may remove the `doctrine/dbal` Composer dependency if you have previously added it to your application, as Laravel is no longer dependent on this package.
<a name="application-structure"></a>
### Application Structure
Laravel 11 introduces a new default application structure with fewer default files. Namely, new Laravel applications contain fewer service providers, middleware, and configuration files.
However, we do **not recommend** that Laravel 10 applications upgrading to Laravel 11 attempt to migrate their application structure, as Laravel 11 has been carefully tuned to also support the Laravel 10 application structure.
<a name="authentication"></a>
### Authentication
<a name="password-rehashing"></a>
#### Password Rehashing
Laravel 11 will automatically rehash your user's passwords during authentication if your hashing algorithm's "work factor" has been updated since the password was last hashed.
Typically, this should not disrupt your application; however, you may disable this behavior by adding the `rehash_on_login` option to your application's `config/hashing.php` configuration file:
'rehash_on_login' => false,
<a name="the-user-provider-contract"></a>
#### The `UserProvider` Contract
**Likelihood Of Impact: Low**
The `Illuminate\Contracts\Auth\UserProvider` contract has received a new `rehashPasswordIfRequired` method. This method is responsible for re-hashing and storing the user's password in storage when the application's hashing algorithm work factor has changed.
If your application or package defines a class that implements this interface, you should add the new `rehashPasswordIfRequired` method to your implementation. A reference implementation can be found within the `Illuminate\Auth\EloquentUserProvider` class:
```php
public function rehashPasswordIfRequired(Authenticatable $user, array $credentials, bool $force = false);
```
<a name="the-authenticatable-contract"></a>
#### The `Authenticatable` Contract
**Likelihood Of Impact: Low**
The `Illuminate\Contracts\Auth\Authenticatable` contract has received a new `getAuthPasswordName` method. This method is responsible for returning the name of your authenticatable entity's password column.
If your application or package defines a class that implements this interface, you should add the new `getAuthPasswordName` method to your implementation:
```php
public function getAuthPasswordName()
{
return 'password';
}
```
The default `User` model included with Laravel receives this method automatically since the method is included within the `Illuminate\Auth\Authenticatable` trait.
<a name="cache"></a>
### Cache
<a name="cache-key-prefixes"></a>
#### Cache Key Prefixes
**Likelihood Of Impact: Very Low**
Previously, if a cache key prefix was defined for the DynamoDB, Memcached, or Redis cache stores, Laravel would append a `:` to the prefix. In Laravel 11, the cache key prefix does not receive the `:` suffix. If you would like to maintain the previous prefixing behavior, you can manually add the `:` suffix to your cache key prefix.
<a name="collections"></a>
### Collections
<a name="the-enumerable-contract"></a>
#### The `Enumerable` Contract
**Likelihood Of Impact: Low**
The `dump` method of the `Illuminate\Support\Enumerable` contract has been updated to accept a variadic `...$args` argument. If you are implementing this interface you should update your implementation accordingly:
```php
public function dump(...$args);
```
<a name="database"></a>
### Database
<a name="sqlite-minimum-version"></a>
#### SQLite 3.35.0+
**Likelihood Of Impact: High**
If your application is utilizing an SQLite database, SQLite 3.35.0 or greater is required.
<a name="eloquent-model-casts-method"></a>
#### Eloquent Model `casts` Method
**Likelihood Of Impact: Low**
The base Eloquent model class now defines a `casts` method in order to support the definition of attribute casts. If one of your application's models is defining a `casts` relationship, it may conflict with the `casts` method now present on the base Eloquent model class.
<a name="modifying-columns"></a>
#### Modifying Columns
**Likelihood Of Impact: High**
When modifying a column, you must now explicitly include all the modifiers you want to keep on the column definition after it is changed. Any missing attributes will be dropped. For example, to retain the `unsigned`, `default`, and `comment` attributes, you must call each modifier explicitly when changing the column, even if those attributes have been assigned to the column by a previous migration.
For example, imagine you have a migration that creates a `votes` column with the `unsigned`, `default`, and `comment` attributes:
```php
Schema::create('users', function (Blueprint $table) {
$table->integer('votes')->unsigned()->default(1)->comment('The vote count');
});
```
Later, you write a migration that changes the column to be `nullable` as well:
```php
Schema::table('users', function (Blueprint $table) {
$table->integer('votes')->nullable()->change();
});
```
In Laravel 10, this migration would retain the `unsigned`, `default`, and `comment` attributes on the column. However, in Laravel 11, the migration must now also include all of the attributes that were previously defined on the column. Otherwise, they will be dropped:
```php
Schema::table('users', function (Blueprint $table) {
$table->integer('votes')
->unsigned()
->default(1)
->comment('The vote count')
->nullable()
->change();
});
```
The `change` method does not change the indexes of the column. Therefore, you may use index modifiers to explicitly add or drop an index when modifying the column:
```php
// Add an index...
$table->bigIncrements('id')->primary()->change();
// Drop an index...
$table->char('postal_code', 10)->unique(false)->change();
```
If you do not want to update all of the existing "change" migrations in your application to retain the column's existing attributes, you may simply [squash your migrations](/docs/{{version}}/migrations#squashing-migrations):
```bash
php artisan schema:dump
```
Once your migrations have been squashed, Laravel will "migrate" the database using your application's schema file before running any pending migrations.
<a name="floating-point-types"></a>
#### Floating-Point Types
**Likelihood Of Impact: High**
The `double` and `float` migration column types have been rewritten to be consistent across all databases.
The `double` column type now creates a `DOUBLE` equivalent column without total digits and places (digits after decimal point), which is the standard SQL syntax. Therefore, you may remove the arguments for `$total` and `$places`:
```php
$table->double('amount');
```
The `float` column type now creates a `FLOAT` equivalent column without total digits and places (digits after decimal point), but with an optional `$precision` specification to determine storage size as a 4-byte single-precision column or an 8-byte double-precision column. Therefore, you may remove the arguments for `$total` and `$places` and specify the optional `$precision` to your desired value and according to your database's documentation:
```php
$table->float('amount', precision: 53);
```
The `unsignedDecimal`, `unsignedDouble`, and `unsignedFloat` methods have been removed, as the unsigned modifier for these column types has been deprecated by MySQL, and was never standardized on other database systems. However, if you wish to continue using the deprecated unsigned attribute for these column types, you may chain the `unsigned` method onto the column's definition:
```php
$table->decimal('amount', total: 8, places: 2)->unsigned();
$table->double('amount')->unsigned();
$table->float('amount', precision: 53)->unsigned();
```
<a name="dedicated-mariadb-driver"></a>
#### Dedicated MariaDB Driver
**Likelihood Of Impact: Very Low**
Instead of always utilizing the MySQL driver when connecting to MariaDB databases, Laravel 11 adds a dedicated database driver for MariaDB.
If your application connects to a MariaDB database, you may update the connection configuration to the new `mariadb` driver to benefit from MariaDB specific features in the future:
'driver' => 'mariadb',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
// ...
Currently, the new MariaDB driver behaves like the current MySQL driver with one exception: the `uuid` schema builder method creates native UUID columns instead of `char(36)` columns.
If your existing migrations utilize the `uuid` schema builder method and you choose to use the new `mariadb` database driver, you should update your migration's invocations of the `uuid` method to `char` to avoid breaking changes or unexpected behavior:
```php
Schema::table('users', function (Blueprint $table) {
$table->char('uuid', 36);
// ...
});
```
<a name="spatial-types"></a>
#### Spatial Types
**Likelihood Of Impact: Low**
The spatial column types of database migrations have been rewritten to be consistent across all databases. Therefore, you may remove `point`, `lineString`, `polygon`, `geometryCollection`, `multiPoint`, `multiLineString`, `multiPolygon`, and `multiPolygonZ` methods from your migrations and use `geometry` or `geography` methods instead:
```php
$table->geometry('shapes');
$table->geography('coordinates');
```
To explicitly restrict the type or the spatial reference system identifier for values stored in the column on MySQL, MariaDB, and PostgreSQL, you may pass the `subtype` and `srid` to the method:
```php
$table->geometry('dimension', subtype: 'polygon', srid: 0);
$table->geography('latitude', subtype: 'point', srid: 4326);
```
The `isGeometry` and `projection` column modifiers of the PostgreSQL grammar have been removed accordingly.
<a name="doctrine-dbal-removal"></a>
#### Doctrine DBAL Removal
**Likelihood Of Impact: Low**
The following list of Doctrine DBAL related classes and methods have been removed. Laravel is no longer dependent on this package and registering custom Doctrines types is no longer necessary for the proper creation and alteration of various column types that previously required custom types:
<div class="content-list" markdown="1">
- `Illuminate\Database\Schema\Builder::$alwaysUsesNativeSchemaOperationsIfPossible` class property
- `Illuminate\Database\Schema\Builder::useNativeSchemaOperationsIfPossible()` method
- `Illuminate\Database\Connection::usingNativeSchemaOperations()` method
- `Illuminate\Database\Connection::isDoctrineAvailable()` method
- `Illuminate\Database\Connection::getDoctrineConnection()` method
- `Illuminate\Database\Connection::getDoctrineSchemaManager()` method
- `Illuminate\Database\Connection::getDoctrineColumn()` method
- `Illuminate\Database\Connection::registerDoctrineType()` method
- `Illuminate\Database\DatabaseManager::registerDoctrineType()` method
- `Illuminate\Database\PDO` directory
- `Illuminate\Database\DBAL\TimestampType` class
- `Illuminate\Database\Schema\Grammars\ChangeColumn` class
- `Illuminate\Database\Schema\Grammars\RenameColumn` class
- `Illuminate\Database\Schema\Grammars\Grammar::getDoctrineTableDiff()` method
</div>
In addition, registering custom Doctrine types via `dbal.types` in your application's `database` configuration file is no longer required.
If you were previously using Doctrine DBAL to inspect your database and its associated tables, you may use Laravel's new native schema methods (`Schema::getTables()`, `Schema::getColumns()`, `Schema::getIndexes()`, `Schema::getForeignKeys()`, etc.) instead.
<a name="deprecated-schema-methods"></a>
#### Deprecated Schema Methods
**Likelihood Of Impact: Very Low**
The deprecated, Doctrine based `Schema::getAllTables()`, `Schema::getAllViews()`, and `Schema::getAllTypes()` methods have been removed in favor of new Laravel native `Schema::getTables()`, `Schema::getViews()`, and `Schema::getTypes()` methods.
When using PostgreSQL and SQL Server, none of the new schema methods will accept a three-part reference (e.g. `database.schema.table`). Therefore, you should use `connection()` to declare the database instead:
```php
Schema::connection('database')->hasTable('schema.table');
```
<a name="get-column-types"></a>
#### Schema Builder `getColumnType()` Method
**Likelihood Of Impact: Very Low**
The `Schema::getColumnType()` method now always returns actual type of the given column, not the Doctrine DBAL equivalent type.
<a name="database-connection-interface"></a>
#### Database Connection Interface
**Likelihood Of Impact: Very Low**
The `Illuminate\Database\ConnectionInterface` interface has received a new `scalar` method. If you are defining your own implementation of this interface, you should add the `scalar` method to your implementation:
```php
public function scalar($query, $bindings = [], $useReadPdo = true);
```
<a name="dates"></a>
### Dates
<a name="carbon-3"></a>
#### Carbon 3
**Likelihood Of Impact: Medium**
Laravel 11 supports both Carbon 2 and Carbon 3. Carbon is a date manipulation library utilized extensively by Laravel and packages throughout the ecosystem. If you install Carbon 3, you should review Carbon's [change log](https://github.com/briannesbitt/Carbon/releases/tag/3.0.0).
<a name="mail"></a>
### Mail
<a name="the-mailer-contract"></a>
#### The `Mailer` Contract
**Likelihood Of Impact: Very Low**
The `Illuminate\Contracts\Mail\Mailer` contract has received a new `sendNow` method. If your application or package is manually implementing this contract, you should add the new `sendNow` method to your implementation:
```php
public function sendNow($mailable, array $data = [], $callback = null);
```
<a name="packages"></a>
### Packages
<a name="publishing-service-providers"></a>
#### Publishing Service Providers to the Application
**Likelihood Of Impact: Very Low**
If you have written a Laravel package that manually publishes a service provider to the application's `app/Providers` directory and manually modifies the application's `config/app.php` configuration file to register the service provider, you should update your package to utilize the new `ServiceProvider::addProviderToBootstrapFile` method.
The `addProviderToBootstrapFile` method will automatically add the service provider you have published to the application's `bootstrap/providers.php` file, since the `providers` array does not exist within the `config/app.php` configuration file in new Laravel 11 applications.
```php
use Illuminate\Support\ServiceProvider;
ServiceProvider::addProviderToBootstrapFile(Provider::class);
```
<a name="queues"></a>
### Queues
<a name="the-batch-repository-interface"></a>
#### The `BatchRepository` Interface
**Likelihood Of Impact: Very Low**
The `Illuminate\Bus\BatchRepository` interface has received a new `rollBack` method. If you are implementing this interface within your own package or application, you should add this method to your implementation:
```php
public function rollBack();
```
<a name="synchronous-jobs-in-database-transactions"></a>
#### Synchronous Jobs in Database Transactions
**Likelihood Of Impact: Very Low**
Previously, synchronous jobs (jobs using the `sync` queue driver) would execute immediately, regardless of whether the `after_commit` configuration option of the queue connection was set to `true` or the `afterCommit` method was invoked on the job.
In Laravel 11, synchronous queue jobs will now respect the "after commit" configuration of the queue connection or job.
<a name="rate-limiting"></a>
### Rate Limiting
<a name="per-second-rate-limiting"></a>
#### Per-Second Rate Limiting
**Likelihood Of Impact: Medium**
Laravel 11 supports per-second rate limiting instead of being limited to per-minute granularity. There are a variety of potential breaking changes you should be aware of related to this change.
The `GlobalLimit` class constructor now accepts seconds instead of minutes. This class is not documented and would not typically be used by your application:
```php
new GlobalLimit($attempts, 2 * 60);
```
The `Limit` class constructor now accepts seconds instead of minutes. All documented usages of this class are limited to static constructors such as `Limit::perMinute` and `Limit::perSecond`. However, if you are instantiating this class manually, you should update your application to provide seconds to the class's constructor:
```php
new Limit($key, $attempts, 2 * 60);
```
The `Limit` class's `decayMinutes` property has been renamed to `decaySeconds` and now contains seconds instead of minutes.
The `Illuminate\Queue\Middleware\ThrottlesExceptions` and `Illuminate\Queue\Middleware\ThrottlesExceptionsWithRedis` class constructors now accept seconds instead of minutes:
```php
new ThrottlesExceptions($attempts, 2 * 60);
new ThrottlesExceptionsWithRedis($attempts, 2 * 60);
```
<a name="cashier-stripe"></a>
### Cashier Stripe
<a name="updating-cashier-stripe"></a>
#### Updating Cashier Stripe
**Likelihood Of Impact: High**
Laravel 11 no longer supports Cashier Stripe 14.x. Therefore, you should update your application's Laravel Cashier Stripe dependency to `^15.0` in your `composer.json` file.
Cashier Stripe 15.0 no longer automatically loads migrations from its own migrations directory. Instead, you should run the following command to publish Cashier Stripe's migrations to your application:
```shell
php artisan vendor:publish --tag=cashier-migrations
```
Please review the complete [Cashier Stripe upgrade guide](https://github.com/laravel/cashier-stripe/blob/15.x/UPGRADE.md) for additional breaking changes.
<a name="spark-stripe"></a>
### Spark (Stripe)
<a name="updating-spark-stripe"></a>
#### Updating Spark Stripe
**Likelihood Of Impact: High**
Laravel 11 no longer supports Laravel Spark Stripe 4.x. Therefore, you should update your application's Laravel Spark Stripe dependency to `^5.0` in your `composer.json` file.
Spark Stripe 5.0 no longer automatically loads migrations from its own migrations directory. Instead, you should run the following command to publish Spark Stripe's migrations to your application:
```shell
php artisan vendor:publish --tag=spark-migrations
```
Please review the complete [Spark Stripe upgrade guide](https://spark.laravel.com/docs/spark-stripe/upgrade.html) for additional breaking changes.
<a name="passport"></a>
### Passport
<a name="updating-telescope"></a>
#### Updating Passport
**Likelihood Of Impact: High**
Laravel 11 no longer supports Laravel Passport 11.x. Therefore, you should update your application's Laravel Passport dependency to `^12.0` in your `composer.json` file.
Passport 12.0 no longer automatically loads migrations from its own migrations directory. Instead, you should run the following command to publish Passport's migrations to your application:
```shell
php artisan vendor:publish --tag=passport-migrations
```
In addition, the password grant type is disabled by default. You may enable it by invoking the `enablePasswordGrant` method in the `boot` method of your application's `AppServiceProvider`:
public function boot(): void
{
Passport::enablePasswordGrant();
}
<a name="sanctum"></a>
### Sanctum
<a name="updating-sanctum"></a>
#### Updating Sanctum
**Likelihood Of Impact: High**
Laravel 11 no longer supports Laravel Sanctum 3.x. Therefore, you should update your application's Laravel Sanctum dependency to `^4.0` in your `composer.json` file.
Sanctum 4.0 no longer automatically loads migrations from its own migrations directory. Instead, you should run the following command to publish Sanctum's migrations to your application:
```shell
php artisan vendor:publish --tag=sanctum-migrations
```
Then, in your application's `config/sanctum.php` configuration file, you should update the references to the `authenticate_session`, `encrypt_cookies`, and `validate_csrf_token` middleware to the following:
'middleware' => [
'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class,
'encrypt_cookies' => Illuminate\Cookie\Middleware\EncryptCookies::class,
'validate_csrf_token' => Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class,
],
<a name="telescope"></a>
### Telescope
<a name="updating-telescope"></a>
#### Updating Telescope
**Likelihood Of Impact: High**
Laravel 11 no longer supports Laravel Telescope 4.x. Therefore, you should update your application's Laravel Telescope dependency to `^5.0` in your `composer.json` file.
Telescope 5.0 no longer automatically loads migrations from its own migrations directory. Instead, you should run the following command to publish Telescope's migrations to your application:
```shell
php artisan vendor:publish --tag=telescope-migrations
```
<a name="spatie-once-package"></a>
### Spatie Once Package
**Likelihood Of Impact: Medium**
Laravel 11 now provides its own [`once` function](/docs/{{version}}/helpers#method-once) to ensure that a given closure is only executed once. Therefore, if your application has a dependency on the `spatie/once` package, you should remove it from your application's `composer.json` file to avoid conflicts.
<a name="miscellaneous"></a>
### Miscellaneous
We also encourage you to view the changes in the `laravel/laravel` [GitHub repository](https://github.com/laravel/laravel). While many of these changes are not required, you may wish to keep these files in sync with your application. Some of these changes will be covered in this upgrade guide, but others, such as changes to configuration files or comments, will not be. You can easily view the changes with the [GitHub comparison tool](https://github.com/laravel/laravel/compare/10.x...11.x) and choose which updates are important to you.
We also encourage you to view the changes in the `laravel/laravel` [GitHub repository](https://github.com/laravel/laravel). While many of these changes are not required, you may wish to keep these files in sync with your application. Some of these changes will be covered in this upgrade guide, but others, such as changes to configuration files or comments, will not be. You can easily view the changes with the [GitHub comparison tool](https://github.com/laravel/laravel/compare/11.x...master) and choose which updates are important to you.