composer require encore/laravel-admin
エラー
Your requirements could not be resolved to an installable set of packages.
Problem 1
- encore/laravel-admin[v1.8.0, ..., v1.8.12] require doctrine/dbal 2.* -> found doctrine/dbal[2.1.5, ..., 2.13.x-dev] but it conflicts with your root composer.json require (^3.1).
- Root composer.json requires encore/laravel-admin ^1.8 -> satisfiable by encore/laravel-admin[v1.8.0, ..., v1.8.12].
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
どうやらdbalのバージョンが3.0だと扱えないようなのでダウングレードする。
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
- "doctrine/dbal": "^3.0",
+ "doctrine/dbal": "2.*",
+ "encore/laravel-admin": "^1.8",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
dbalを3⇨2にする。
composer require "doctrine/dbal:2.*"
composer require encore/laravel-admin
$php artisan vendor:publish --provider="Encore\Admin\AdminServiceProvider"
$php artisan admin:install
app/Admin
├── Controllers
│ ├── ExampleController.php
│ └── HomeController.php
├── bootstrap.php
└── routes.php
(上記を自分の環境によって都度書き換えて下さい。php artisan serve
でhttp://localhost:8000/admin ) でローカル開発をしている方が多いのではないでしょうか??
DBに接続するために以下のモデルを実行します。
以下の管理画面が出ますので、user画面,パスワード共にadminでログインします。
本番環境でこれを使うのはあまりにも危険すぎるので管理者などに確認して扱うのが無難かと、、自分の場合は一人なので確認する人もいないのですが
php artisan make:model Recipe
php artisan admin:make RecipeController --model=App\\models\\Recipe
App\Admin\Controllers\RecipeController created successfully.
Add the following route to app/Admin/routes.php:
$router->resource('recipes', RecipeController::class);
とりあえず以下を解消する。
Disk [admin] not configured, please add a disk config in `config/filesystems.php`.
Disk [admin] not configured, please add a disk config in `config/filesystems.php`.
ってことなので追加します。
該当のファイルは以下のようになっています。
config/filesystems.php
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
],
],
まあファイルアップロード用のphpファイルってとこですかね。file.phpについては割愛します。
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL') . '/storage',
'visibility' => 'public',
],
↓↓↓追加↓↓↓
'admin' => [
'driver' => 'local',
'root' => public_path('uploads'),
'visibility' => 'public',
'url' => env('APP_URL') . '/uploads',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
],
],
消えたんでおっさんとさよならします。
おっさんとはさよならしましたが、肝心な画像が表示されません。がまた後日。
※今のところdbalはバージョン2.0が必要な模様