Skip to content

Commit 50bf798

Browse files
Add support for Laravel 12 (#494)
A new version of Laravel was release. We did create the Laravel Example from stretch with the new 12 version and so make sure our example matches current laravel best practices.
1 parent ac60001 commit 50bf798

30 files changed

+1056
-709
lines changed

.examples/laravel/.env.example

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
APP_NAME=Laravel
22
APP_ENV=local
3-
APP_KEY=base64:OHd3Mzh0M25nNnFlczJnYWVuNjcwejJxNnl3eXBnMG0=
3+
APP_KEY=base64:BwuZAzyu5OBaUExGnOWk5Ox+u4AP6YFY/A/MrKlvhb0=
44
APP_DEBUG=true
5-
APP_TIMEZONE=UTC
65
APP_URL=http://localhost
76

87
APP_LOCALE=en
98
APP_FALLBACK_LOCALE=en
109
APP_FAKER_LOCALE=en_US
1110

1211
APP_MAINTENANCE_DRIVER=file
13-
APP_MAINTENANCE_STORE=database
12+
# APP_MAINTENANCE_STORE=database
13+
14+
PHP_CLI_SERVER_WORKERS=4
1415

1516
BCRYPT_ROUNDS=12
1617

@@ -37,7 +38,7 @@ FILESYSTEM_DISK=local
3738
QUEUE_CONNECTION=database
3839

3940
CACHE_STORE=database
40-
CACHE_PREFIX=
41+
# CACHE_PREFIX=
4142

4243
MEMCACHED_HOST=127.0.0.1
4344

@@ -47,11 +48,11 @@ REDIS_PASSWORD=null
4748
REDIS_PORT=6379
4849

4950
MAIL_MAILER=log
51+
MAIL_SCHEME=null
5052
MAIL_HOST=127.0.0.1
5153
MAIL_PORT=2525
5254
MAIL_USERNAME=null
5355
MAIL_PASSWORD=null
54-
MAIL_ENCRYPTION=null
5556
MAIL_FROM_ADDRESS="[email protected]"
5657
MAIL_FROM_NAME="${APP_NAME}"
5758

.examples/laravel/.gitignore

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@
44
/public/hot
55
/public/storage
66
/storage/*.key
7+
/storage/pail
78
/vendor
89
.env
910
.env.backup
1011
.env.production
12+
.phpactor.json
1113
.phpunit.result.cache
1214
Homestead.json
1315
Homestead.yaml
14-
auth.json
1516
npm-debug.log
1617
yarn-error.log
18+
/auth.json
1719
/.fleet
1820
/.idea
21+
/.nova
1922
/.vscode
20-
21-
/.php-cs-fixer.cache
22-
/phpstan.neon
23+
/.zed

.examples/laravel/app/Models/User.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,21 @@
44

55
namespace App\Models;
66

7-
use Database\Factories\UserFactory;
87
// use Illuminate\Contracts\Auth\MustVerifyEmail;
98
use Illuminate\Database\Eloquent\Factories\HasFactory;
109
use Illuminate\Foundation\Auth\User as Authenticatable;
1110
use Illuminate\Notifications\Notifiable;
1211

1312
class User extends Authenticatable
1413
{
15-
/**
16-
* @phpstan-use HasFactory<UserFactory>
17-
*/
14+
/** @use HasFactory<\Database\Factories\UserFactory> */
1815
use HasFactory;
1916
use Notifiable;
2017

2118
/**
2219
* The attributes that are mass assignable.
2320
*
24-
* @var array<int, string>
21+
* @var list<string>
2522
*/
2623
protected $fillable = [
2724
'name',
@@ -32,7 +29,7 @@ class User extends Authenticatable
3229
/**
3330
* The attributes that should be hidden for serialization.
3431
*
35-
* @var array<int, string>
32+
* @var list<string>
3633
*/
3734
protected $hidden = [
3835
'password',

.examples/laravel/artisan

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env php
22
<?php
33

4+
use Illuminate\Foundation\Application;
45
use Symfony\Component\Console\Input\ArgvInput;
56

67
define('LARAVEL_START', microtime(true));
@@ -9,7 +10,9 @@ define('LARAVEL_START', microtime(true));
910
require __DIR__.'/vendor/autoload.php';
1011

1112
// Bootstrap Laravel and handle the command...
12-
$status = (require_once __DIR__.'/bootstrap/app.php')
13-
->handleCommand(new ArgvInput);
13+
/** @var Application $app */
14+
$app = require_once __DIR__.'/bootstrap/app.php';
15+
16+
$status = $app->handleCommand(new ArgvInput);
1417

1518
exit($status);

.examples/laravel/composer.json

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
{
2+
"$schema": "https://getcomposer.org/schema.json",
23
"name": "laravel/laravel",
34
"type": "project",
45
"description": "The skeleton application for the Laravel framework.",
56
"keywords": ["laravel", "framework"],
67
"license": "MIT",
7-
"minimum-stability": "dev",
8-
"prefer-stable": true,
98
"require": {
109
"php": "^8.2",
11-
"laravel/framework": "^11.0",
12-
"laravel/tinker": "^2.9",
10+
"laravel/framework": "^12.0",
11+
"laravel/tinker": "^2.10.1",
1312
"cmsig/seal": "^0.7",
1413
"cmsig/seal-laravel-package": "^0.7"
1514
},
1615
"require-dev": {
1716
"fakerphp/faker": "^1.23",
17+
"laravel/pail": "^1.2.2",
1818
"laravel/pint": "^1.13",
19-
"laravel/sail": "^1.26",
19+
"laravel/sail": "^1.41",
2020
"mockery/mockery": "^1.6",
21-
"nunomaduro/collision": "^8.0",
22-
"phpunit/phpunit": "^10.5",
23-
"pestphp/pest": "^2.16",
21+
"nunomaduro/collision": "^8.6",
22+
"pestphp/pest": "^3.7",
2423
"php-cs-fixer/shim": "^3.51",
2524
"phpstan/extension-installer": "^1.2",
2625
"phpstan/phpstan": "^1.10",
@@ -90,10 +89,11 @@
9089
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
9190
"@php artisan migrate --graceful --ansi"
9291
],
93-
"post-install-cmd": [
94-
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
95-
"@php artisan key:generate --ansi"
92+
"dev": [
93+
"Composer\\Config::disableProcessTimeout",
94+
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite"
9695
],
96+
"serve": "@php artisan serve",
9797
"test": [
9898
"Composer\\Config::disableProcessTimeout",
9999
"vendor/bin/pest"
@@ -129,5 +129,7 @@
129129
"php-http/discovery": true,
130130
"phpstan/extension-installer": true
131131
}
132-
}
132+
},
133+
"minimum-stability": "dev",
134+
"prefer-stable": true
133135
}

0 commit comments

Comments
 (0)