Skip to content

Commit 6513614

Browse files
Upgrading to Laravel 11.x
1 parent 2afb2d8 commit 6513614

40 files changed

+5701
-3464
lines changed

.env.example

+1-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ APP_DEBUG=true
55
APP_URL=http://laravel-blog.test
66
LOG_CHANNEL=stack
77

8-
DB_CONNECTION=mysql
9-
DB_HOST=127.0.0.1
10-
DB_DATABASE=homestead
11-
DB_USERNAME=homestead
12-
DB_PASSWORD=secret
8+
DB_CONNECTION=sqlite
139

1410
BROADCAST_DRIVER=pusher
1511
CACHE_DRIVER=file

.eslintrc.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// https://eslint.org/docs/user-guide/configuring
2+
13
module.exports = {
24
env: {
35
browser: true,
@@ -12,7 +14,6 @@ module.exports = {
1214
$: false
1315
},
1416
parserOptions: {
15-
ecmaVersion: 2018,
1617
sourceType: 'module'
1718
},
1819
rules: {

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,10 @@ public/build/
2020
.phpunit.result.cache
2121
pint.json
2222
storage/media-library/temp
23+
.pnp.*
24+
.yarn/*
25+
!.yarn/patches
26+
!.yarn/plugins
27+
!.yarn/releases
28+
!.yarn/sdks
29+
!.yarn/versions

.node-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20

.yarnrc.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Guillaume Briday
3+
Copyright (c) Guillaume Briday
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+27-25
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
# Laravel 10.x blog
1+
# Laravel 11.x blog
22

33
The purpose of this repository is to show good development practices on [Laravel](http://laravel.com/) as well as to present cases of use of the framework's features like:
44

5-
- [Authentication](https://laravel.com/docs/10.x/authentication)
5+
- [Authentication](https://laravel.com/docs/11.x/authentication)
66
- API
7-
- [Sanctum](https://laravel.com/docs/10.x/sanctum)
8-
- [API Resources](https://laravel.com/docs/10.x/eloquent-resources)
7+
- [Sanctum](https://laravel.com/docs/11.x/sanctum)
8+
- [API Resources](https://laravel.com/docs/11.x/eloquent-resources)
99
- Versioning
10-
- [Blade](https://laravel.com/docs/10.x/blade)
11-
- [Broadcasting](https://laravel.com/docs/10.x/broadcasting)
12-
- [Cache](https://laravel.com/docs/10.x/cache)
13-
- [Email Verification](https://laravel.com/docs/10.x/verification)
14-
- [Filesystem](https://laravel.com/docs/10.x/filesystem)
15-
- [Helpers](https://laravel.com/docs/10.x/helpers)
16-
- [Horizon](https://laravel.com/docs/10.x/horizon)
17-
- [Localization](https://laravel.com/docs/10.x/localization)
18-
- [Mail](https://laravel.com/docs/10.x/mail)
19-
- [Migrations](https://laravel.com/docs/10.x/migrations)
20-
- [Policies](https://laravel.com/docs/10.x/authorization)
21-
- [Providers](https://laravel.com/docs/10.x/providers)
22-
- [Requests](https://laravel.com/docs/10.x/validation#form-request-validation)
23-
- [Seeding & Factories](https://laravel.com/docs/10.x/seeding)
24-
- [Testing](https://laravel.com/docs/10.x/testing)
25-
- [Homestead](https://laravel.com/docs/10.x/homestead)
10+
- [Blade](https://laravel.com/docs/11.x/blade)
11+
- [Broadcasting](https://laravel.com/docs/11.x/broadcasting)
12+
- [Cache](https://laravel.com/docs/11.x/cache)
13+
- [Email Verification](https://laravel.com/docs/11.x/verification)
14+
- [Filesystem](https://laravel.com/docs/11.x/filesystem)
15+
- [Helpers](https://laravel.com/docs/11.x/helpers)
16+
- [Horizon](https://laravel.com/docs/11.x/horizon)
17+
- [Localization](https://laravel.com/docs/11.x/localization)
18+
- [Mail](https://laravel.com/docs/11.x/mail)
19+
- [Migrations](https://laravel.com/docs/11.x/migrations)
20+
- [Policies](https://laravel.com/docs/11.x/authorization)
21+
- [Providers](https://laravel.com/docs/11.x/providers)
22+
- [Requests](https://laravel.com/docs/11.x/validation#form-request-validation)
23+
- [Seeding & Factories](https://laravel.com/docs/11.x/seeding)
24+
- [Testing](https://laravel.com/docs/11.x/testing)
25+
- [Homestead](https://laravel.com/docs/11.x/homestead)
2626

2727
Beside Laravel, this project uses other tools like:
2828

@@ -41,7 +41,7 @@ You can find some screenshots of the application on : [https://imgur.com/a/Jbnwj
4141

4242
## Installation
4343

44-
To create your development environment [follow these instructions](https://laravel.com/docs/10.x/installation).
44+
To create your development environment [follow these instructions](https://laravel.com/docs/11.x/installation#local-installation-using-herd).
4545

4646
Setting up your development environment on your local machine:
4747
```bash
@@ -54,6 +54,8 @@ $ php artisan telescope:install
5454
$ php artisan storage:link
5555
```
5656

57+
Now open [http://laravel-blog.test](http://laravel-blog.test).
58+
5759
### Mailer
5860

5961
You can use [Mailpit](https://github.com/axllent/mailpit) to test your emails in development.
@@ -63,18 +65,18 @@ Once installed, open [http://localhost:8025](http://localhost:8025).
6365
## Before starting
6466
You need to run the migrations with the seeds :
6567
```bash
66-
$ php artisan migrate --seed
68+
$ php artisan migrate:fresh --seed
6769
```
6870

6971
This will create a new user that you can use to sign in :
7072
```yml
71-
72-
password: 4nak1n
73+
74+
password: demodemo
7375
```
7476
7577
And then, compile the assets :
7678
```bash
77-
$ yarn dev # or yarn watch
79+
$ yarn dev
7880
```
7981

8082
Starting job for newsletter :

app/Http/Controllers/CommentController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
use App\Http\Requests\CommentsRequest;
66
use App\Models\Comment;
7+
use HotwiredLaravel\TurboLaravel\Http\MultiplePendingTurboStreamResponse;
78
use Illuminate\Support\Facades\Auth;
8-
use Tonysm\TurboLaravel\Http\MultiplePendingTurboStreamResponse;
99

1010
class CommentController extends Controller
1111
{

app/Http/Controllers/PostLikeController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
namespace App\Http\Controllers;
44

55
use App\Models\Post;
6+
use HotwiredLaravel\TurboLaravel\Http\MultiplePendingTurboStreamResponse;
67
use Illuminate\Support\Str;
7-
use Tonysm\TurboLaravel\Http\MultiplePendingTurboStreamResponse;
88

9-
use function Tonysm\TurboLaravel\dom_id;
9+
use function HotwiredLaravel\TurboLaravel\dom_id;
1010

1111
class PostLikeController extends Controller
1212
{

app/Http/Kernel.php

-69
This file was deleted.

app/Models/Post.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function getRouteKeyName(): string
7474
public function scopeSearch(Builder $query, ?string $search)
7575
{
7676
if ($search) {
77-
return $query->where('title', 'ILIKE', "%{$search}%");
77+
return $query->where('title', 'LIKE', "%{$search}%");
7878
}
7979
}
8080

app/Models/User.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace App\Models;
44

5-
use Illuminate\Contracts\Auth\MustVerifyEmail;
65
use Illuminate\Database\Eloquent\Builder;
76
use Illuminate\Database\Eloquent\Factories\HasFactory;
87
use Illuminate\Database\Eloquent\Relations\belongsToMany;
@@ -12,7 +11,7 @@
1211
use Illuminate\Support\Str;
1312
use Laravel\Sanctum\HasApiTokens;
1413

15-
class User extends Authenticatable implements MustVerifyEmail
14+
class User extends Authenticatable
1615
{
1716
use HasApiTokens, HasFactory, Notifiable;
1817

bootstrap/app.php

+54-53
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,56 @@
11
<?php
22

3-
/*
4-
|--------------------------------------------------------------------------
5-
| Create The Application
6-
|--------------------------------------------------------------------------
7-
|
8-
| The first thing we will do is create a new Laravel application instance
9-
| which serves as the "glue" for all the components of Laravel, and is
10-
| the IoC container for the system binding all of the various parts.
11-
|
12-
*/
13-
14-
$app = new Illuminate\Foundation\Application(
15-
realpath(__DIR__ . '/../')
16-
);
17-
18-
/*
19-
|--------------------------------------------------------------------------
20-
| Bind Important Interfaces
21-
|--------------------------------------------------------------------------
22-
|
23-
| Next, we need to bind some important interfaces into the container so
24-
| we will be able to resolve them when needed. The kernels serve the
25-
| incoming requests to this application from both the web and CLI.
26-
|
27-
*/
28-
29-
$app->singleton(
30-
Illuminate\Contracts\Http\Kernel::class,
31-
App\Http\Kernel::class
32-
);
33-
34-
$app->singleton(
35-
Illuminate\Contracts\Console\Kernel::class,
36-
App\Console\Kernel::class
37-
);
38-
39-
$app->singleton(
40-
Illuminate\Contracts\Debug\ExceptionHandler::class,
41-
App\Exceptions\Handler::class
42-
);
43-
44-
/*
45-
|--------------------------------------------------------------------------
46-
| Return The Application
47-
|--------------------------------------------------------------------------
48-
|
49-
| This script returns the application instance. The instance is given to
50-
| the calling script so we can separate the building of the instances
51-
| from the actual running of the application and sending responses.
52-
|
53-
*/
54-
55-
return $app;
3+
use Illuminate\Foundation\Application;
4+
use Illuminate\Foundation\Configuration\Exceptions;
5+
use Illuminate\Foundation\Configuration\Middleware;
6+
7+
return Application::configure(basePath: dirname(__DIR__))
8+
->withRouting(
9+
web: __DIR__ . '/../routes/web.php',
10+
commands: __DIR__ . '/../routes/console.php',
11+
health: '/up',
12+
)
13+
->withMiddleware(function (Middleware $middleware) {
14+
$middleware->use([
15+
// \App\Http\Middleware\TrustHosts::class,
16+
\App\Http\Middleware\TrustProxies::class,
17+
\Illuminate\Http\Middleware\HandleCors::class,
18+
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
19+
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
20+
\App\Http\Middleware\TrimStrings::class,
21+
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
22+
]);
23+
24+
$middleware->group('web', [
25+
\App\Http\Middleware\EncryptCookies::class,
26+
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
27+
\Illuminate\Session\Middleware\StartSession::class,
28+
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
29+
\App\Http\Middleware\VerifyCsrfToken::class,
30+
\Illuminate\Routing\Middleware\SubstituteBindings::class,
31+
]);
32+
33+
$middleware->group('api', [
34+
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
35+
\Illuminate\Routing\Middleware\ThrottleRequests::class . ':api',
36+
\Illuminate\Routing\Middleware\SubstituteBindings::class,
37+
]);
38+
39+
$middleware->alias([
40+
'auth' => \App\Http\Middleware\Authenticate::class,
41+
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
42+
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
43+
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
44+
'can' => \Illuminate\Auth\Middleware\Authorize::class,
45+
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
46+
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
47+
'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class,
48+
'signed' => \App\Http\Middleware\ValidateSignature::class,
49+
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
50+
'role' => \App\Http\Middleware\RoleMiddleware::class,
51+
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
52+
]);
53+
})
54+
->withExceptions(function (Exceptions $exceptions) {
55+
//
56+
})->create();

0 commit comments

Comments
 (0)