Skip to content

Conversation

@shanto
Copy link

@shanto shanto commented Nov 2, 2025

Support for Docker based PHP environment configurable with config keys:

{
"Laravel.dockerService": "php", // from docker compose config --services
"Laravel.dockerBase": "/app", // from docker compose exec {dockerService} pwd
}

This plugin does not auto boot Docker container(s) although it can be implemented in later revisions. For now, ensure that Docker container is running with configured dockerService name and dockerBase path as working directory before attempting to use the plugin with Docker support.

Addressing #191

With this commit, Docker environment should be supported and visible in Laravel extension log like...

2025-11-02 17:00:22.076 [info] Activating Laravel Extension...
2025-11-02 17:00:22.076 [info] Started
2025-11-02 17:00:22.076 [info] Checking herd PHP installation: herd which-php
2025-11-02 17:00:22.076 [info] Checking valet PHP installation: valet which-php
2025-11-02 17:00:22.076 [info] Checking sail PHP installation: ./vendor/bin/sail ps
2025-11-02 17:00:22.076 [info] Checking lando PHP installation: lando php -r 'echo PHP_BINARY;'
2025-11-02 17:00:22.076 [info] Checking ddev PHP installation: ddev php -r 'echo PHP_BINARY;'
2025-11-02 17:00:22.076 [info] Checking docker PHP installation: docker compose exec php which php
2025-11-02 17:00:22.076 [info] Using docker PHP installation: /usr/bin/php

@shanto
Copy link
Author

shanto commented Nov 2, 2025

.vscode/settings.json

{
"Laravel.phpEnvironment": "docker",
"Laravel.dockerService": "php", // from docker compose config --services
"Laravel.dockerBase": "/app", // from docker compose exec {dockerService} pwd
}

dockerService should point to the service name of the container having PHP source file and PHP interpreter as defined in docker-compose.yml. In our example it is php. dockerBase should point to the base directory of the app inside container, which is /app in our example setup.

This is enough to get started if you have an existing Docker setup and you have figured out source code synchronization or if you are bind mounting your source tree. For other conditions, see below.


docker-compose.yml

name: laravel-vscode-docker

services:
  php:
    cpus: 4
    environment:
      DOC_ROOT: /app/public
      PHP_INI: "max_execution_time=60;post_max_size=64M"
    image: yafarhad/php-dev
    tty: true
    restart: no
    ports:
      - 80
    volumes:
      - app:/app
      - ./vendor/_laravel_ide:/app/vendor/_laravel_ide
    user: docker

volumes:
  app:

Bind mount (no mutagen) source tree

    ...
    volumes:
      - .:/app
    ...

mutagen.yml
(for high performance synchronization of local ↔ docker source tree)

sync:
  defaults:
    ignore:
      vcs: true
  laravel-vscode-docker:
    alpha: "." # your project root
    beta: "docker://laravel-vscode-docker-php-1/app" # NAME from `docker container ls`
    mode: "two-way-resolved"
    ignore:
      paths:
        - /vendor/_laravel_ide/
beforeCreate:
  - docker-compose up --build --wait
afterTerminate:
  - docker-compose down

Steps to empty project setup

Create docker-compose.yml and mutagen.yml following above examples.

  • # scoop install main/mutagen
  • mutagen project start or docker compose up --build -d
  • docker compose exec --user root php chown -R docker:docker .

Steps to bootstrap a Laravel app

  • docker compose exec php sh then inside Docker shell:
  • rm -rf /tmp/app; composer create-project laravel/laravel /tmp/app
  • find /tmp/app/ -maxdepth 1 -mindepth 1 -exec cp -rf {} /app/ \; ; rm -rf /tmp/app

Special Note

If vendor/_laravel_ide is synchronized by any means, there is a delay between when Laravel IDE creates files inside this folder, and when it actually gets copied into the container. Therefore, it is always safest to bind mount this particular directory.

Support for Docker based PHP environment configurable with config keys:

{
    "Laravel.dockerService": "php", // from `docker compose config --services`
    "Laravel.dockerBase": "/app", // from `docker compose exec {dockerService} pwd`
}

This plugin does not auto boot Docker container(s) although it can be implemented in later revisions. For now, ensure that Docker container is running with configured dockerService name and dockerBase path as working directory before attempting to use the plugin with Docker support.
@bradley-varol-ep-tech
Copy link

This is exactly what I need! Can we get this merged?

@shanto
Copy link
Author

shanto commented Nov 21, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants