Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kevinbanami's avatar

Custom Artisan Commands Not Showing in Laravel 11/12 (Dockerized Environment)

Hi all,

After upgrading my Laravel project from v10 to v11, I noticed that my custom Artisan commands are no longer being registered in my Dockerized local environment. This was working fine in Laravel 10.

I also tested this in a fresh Laravel 12 (Dockerized) setup and faced the same issue.

Example:

Inside Docker container: php artisan make:command TestCustomCommand

Then trying to run it: php artisan app:test-custom-command

Output: ERROR There are no commands defined in the "app" namespace.

The command also doesn’t appear in php artisan list.

However, on my production server (non-Docker, Laravel 11) the exact same command does show up and executes correctly.

Things I’ve checked/tried:

  • Command is in the correct namespace (App\Console\Commands) and has a valid $signature.
  • Manually calling the command class works ((new TestCustomCommand)->handle()).
  • Ran composer dump-autoload, php artisan optimize:clear, etc.
  • Rebuilt Docker containers completely.
  • Set commands folder permissions to 777 to test.
  • Tried explicitly registering with withCommands() in bootstrap/app.php.

Bottom line: I suspect this is Docker-related, but I haven’t found documentation pointing to what could be missing. Any pointers or ideas would be greatly appreciated.

If helpful, I can share my docker-compose.yml as well — just didn’t want to bloat the post.

Thanks in advance! Kevin

0 likes
1 reply
Braunson's avatar

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:

  1. Are you using bind mounts or Docker volumes for your code?
  2. What's your host OS (Windows, macOS, Linux)?
  3. 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.

Please or to participate in this conversation.