This is likely a Docker volume mounting or file synchronization issue specific to Laravel 11/12's new application structure. The commands exist on your host but aren't being properly reflected in the container's filesystem.
Quick questions:
- Are you using bind mounts or Docker volumes for your code?
- What's your host OS (Windows, macOS, Linux)?
- Are other new files (controllers, models) created inside the container visible on the host and vice versa?
Most common causes:
Volume Mount Issues:
# Check your docker-compose.yml volumes section
services:
app:
volumes:
- .:/var/www/html # Should mount entire project
# NOT just - ./src:/var/www/html/src
File Sync Problems (especially macOS/Windows):
# Test file visibility both ways
# Inside container:
touch /var/www/html/test-container.txt
# On host:
touch test-host.txt
# Check if both are visible in both environments
Laravel 11/12 Bootstrap Changes:
The new bootstrap/app.php structure might need explicit command registration:
// bootstrap/app.php
return Application::configure(basePath: dirname(__DIR__))
->withCommands([
\App\Console\Commands\TestCustomCommand::class,
])
// ... rest of config
Quick Debug Steps:
# Inside container, check if file exists
ls -la app/Console/Commands/
cat app/Console/Commands/TestCustomCommand.php
# Check autoload
composer dump-autoload -v
What does docker-compose.yml look like for the volumes section? That's usually where the issue lies.