Laravel 11でconfig/*.phpがなくなるってよ🗑️

https://laravel.com/docs/master/releases#health:~:text=Configuration%20Files

Laravel 11で`config/*.php`がなくなります！
不要なconfigをバージョン管理しなくなることで認知負荷が下がり生産性が上がります！
Laravelのバージョンアップ時に考慮することが減ります！

# Laravel 11のインストール
Laravel 11はPHP8.2以上が必要です
```bash
composer create-project laravel/laravel:^11.0 example-app
cd example-app
php artisan serve
```

# 基本的には環境変数使ってconfig/*.phpは作らないようにしよう！

`.env`ファイルに環境変数を設定しよう！Laravel 10以前の `config/*.php` は、https://github.com/laravel/framework/tree/master/config に移動しました！

使用できる環境変数の一覧
```bash
cd vendor/laravel/framework/
grep -hPo "(?<=')[A-Z]+_[A-Z_]+(?=')" config/*.php | sort | uniq | while read name; do echo $name=$((grep -hPo "(?<='$name', ').*(?='\))" config/*.php || grep -hPo "(?<='$name', ).*(?=\))" config/*.php) | head -1); done
```

```php
ABLY_KEY=
APP_DEBUG=false
APP_ENV=production
APP_FAKER_LOCALE=en_US
APP_FALLBACK_LOCALE=en
APP_KEY=
APP_LOCALE=en
APP_MAINTENANCE_DRIVER=file
APP_MAINTENANCE_STORE=database
APP_NAME=Laravel
APP_PREVIOUS_KEYS=
APP_TIMEZONE=UTC
APP_URL=http://localhost
ARGON_MEMORY=65536
ARGON_THREADS=1
ARGON_TIME=4
ASSET_URL=
AUTH_GUARD=web
AUTH_MODEL=App\Models\User::class
AUTH_PASSWORD_TIMEOUT=10800
AWS_ACCESS_KEY_ID=
AWS_BUCKET=
AWS_DEFAULT_REGION=us-east-1
AWS_ENDPOINT=
AWS_SECRET_ACCESS_KEY=
AWS_URL=
AWS_USE_PATH_STYLE_ENDPOINT=false
BCRYPT_ROUNDS=12
BEANSTALKD_QUEUE=default
BEANSTALKD_QUEUE_HOST=localhost
BEANSTALKD_QUEUE_RETRY_AFTER=90
BROADCAST_CONNECTION=null
CACHE_PREFIX=Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'
CACHE_STORE=database
DB_CACHE_CONNECTION=null
DB_CACHE_LOCK_CONNECTION=null
DB_CACHE_TABLE=cache
DB_CONNECTION=sqlite
DB_DATABASE=laravel
DB_ENCRYPT=yes
DB_FOREIGN_KEYS=true
DB_HOST=127.0.0.1
DB_PASSWORD=
DB_PORT=3306
DB_QUEUE=default
DB_QUEUE_CONNECTION=null
DB_QUEUE_RETRY_AFTER=90
DB_QUEUE_TABLE=jobs
DB_SOCKET=
DB_TRUST_SERVER_CERTIFICATE=false
DB_URL=
DB_USERNAME=root
DYNAMODB_CACHE_TABLE=cache
DYNAMODB_ENDPOINT=
FILESYSTEM_DISK=local
FRONTEND_URL=http://localhost:3000
HASH_DRIVER=bcrypt
LOG_CHANNEL=stack
LOG_DAILY_DAYS=14
LOG_DEPRECATIONS_CHANNEL=null
LOG_DEPRECATIONS_TRACE=false
LOG_LEVEL=debug
LOG_PAPERTRAIL_HANDLER=SyslogUdpHandler::class
LOG_SLACK_EMOJI=:boom:
LOG_SLACK_USERNAME=Laravel Log
LOG_SLACK_WEBHOOK_URL=
LOG_STACK=single
LOG_STDERR_FORMATTER=
LOG_SYSLOG_FACILITY=LOG_USER
MAILGUN_DOMAIN=
MAILGUN_ENDPOINT=api.mailgun.net
MAILGUN_SECRET=
MAIL_EHLO_DOMAIN=
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=hello@example.com
MAIL_FROM_NAME=Example
MAIL_HOST=127.0.0.1
MAIL_LOG_CHANNEL=
MAIL_MAILER=log
MAIL_MARKDOWN_THEME=default
MAIL_PASSWORD=
MAIL_PORT=2525
MAIL_SENDMAIL_PATH=/usr/sbin/sendmail -bs -i
MAIL_URL=
MAIL_USERNAME=
MEMCACHED_HOST=127.0.0.1
MEMCACHED_PASSWORD=
MEMCACHED_PERSISTENT_ID=
MEMCACHED_PORT=11211
MEMCACHED_USERNAME=
MYSQL_ATTR_SSL_CA=
PAPERTRAIL_PORT=
PAPERTRAIL_URL=
POSTMARK_TOKEN=
PUSHER_APP_CLUSTER=mt1
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
QUEUE_CONNECTION=database
QUEUE_FAILED_DRIVER=database-uuids
REDIS_BROADCASTING_CONNECTION=default
REDIS_CACHE_CONNECTION=cache
REDIS_CACHE_DB=1
REDIS_CACHE_LOCK_CONNECTION=default
REDIS_CLIENT=phpredis
REDIS_CLUSTER=redis
REDIS_DB=0
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=
REDIS_PORT=6379
REDIS_PREFIX=Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'
REDIS_QUEUE=default
REDIS_QUEUE_CONNECTION=default
REDIS_QUEUE_RETRY_AFTER=90
REDIS_URL=
REDIS_USERNAME=
RESEND_KEY=
REVERB_APP_ID=
REVERB_APP_KEY=
REVERB_APP_SECRET=
REVERB_HOST=
REVERB_PORT=443
REVERB_SCHEME=https
SESSION_CONNECTION=
SESSION_COOKIE=
SESSION_DOMAIN=
SESSION_DRIVER=database
SESSION_ENCRYPT=false
SESSION_EXPIRE_ON_CLOSE=false
SESSION_HTTP_ONLY=true
SESSION_LIFETIME=120
SESSION_PARTITIONED_COOKIE=false
SESSION_PATH=/
SESSION_SAME_SITE=lax
SESSION_SECURE_COOKIE=
SESSION_STORE=
SESSION_TABLE=sessions
SLACK_BOT_USER_DEFAULT_CHANNEL=
SLACK_BOT_USER_OAUTH_TOKEN=
SQS_PREFIX=https://sqs.us-east-1.amazonaws.com/your-account-id
SQS_QUEUE=default
SQS_SUFFIX=
VIEW_COMPILED_PATH=
```

# configファイル作ることもできる！

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/435735/055d1698-2a9a-9141-3caa-e5a3fe16d154.png)

```bash
# インタラクティブにconfigファイル作る
php artisan config:publish

# 個別にconfigファイル作る
php artisan config:publish app
php artisan config:publish auth
php artisan config:publish broadcasting
php artisan config:publish cache
php artisan config:publish cors
php artisan config:publish database
php artisan config:publish filesystems
php artisan config:publish hashing
php artisan config:publish logging
php artisan config:publish mail
php artisan config:publish queue
php artisan config:publish sanctum
php artisan config:publish services
php artisan config:publish session
php artisan config:publish view

# すべてのconfigファイル作る
php artisan config:publish --all
```