Laravel Bootcampを試している時に、
tinkerで”Error Class “Chirp” not found.”というエラーが表示されました。
$ php artisan tinker
Psy Shell v0.11.18 (PHP 8.1.14 — cli) by Justin Hileman
> Chirp::all();
Error Class "Chirp" not found.
composer dump-autoloadを実行すると、エラーが解消しました。
$ composer dump-autoload
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
INFO Discovering packages.
laravel/breeze ........................................................ DONE
laravel/sail .......................................................... DONE
laravel/sanctum ....................................................... DONE
laravel/tinker ........................................................ DONE
nesbot/carbon ......................................................... DONE
nunomaduro/collision .................................................. DONE
nunomaduro/termwind ................................................... DONE
spatie/laravel-ignition ............................................... DONE
Generated optimized autoload files containing 5834 classes
$php artisan tinker
Psy Shell v0.11.18 (PHP 8.1.14 — cli) by Justin Hileman
> Chirp::all();
[!] Aliasing 'Chirp' to 'App\Models\Chirp' for this Tinker session.
= Illuminate\Database\Eloquent\Collection {#7211
all: [
App\Models\Chirp {#7213
id: 1,
user_id: 1,
message: "hello!!",
created_at: "2023-06-13 09:51:54",
updated_at: "2023-06-13 09:51:54",
},
],
}