diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..6abd30d --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,28 @@ +{ + "name": "debugphp-server", + "dockerComposeFile": "../docker-compose.yml", + "service": "app", + "workspaceFolder": "/var/www/html", + "forwardPorts": [ + 8787 + ], + "portsAttributes": { + "8787": { + "label": "DebugPHP Server" + } + }, + "postCreateCommand": "composer install", + "customizations": { + "vscode": { + "extensions": [ + "bmewburn.vscode-intelephense-client", + "xdebug.php-pack", + "EditorConfig.EditorConfig" + ], + "settings": { + "php.validate.executablePath": "/usr/local/bin/php", + "intelephense.environment.phpVersion": "8.4" + } + } + } +} \ No newline at end of file diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b4f798e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,16 @@ +.git +.gitignore + +Dockerfile +docker-compose.yml +.dockerignore + +.env +.env.* + +data/ + +vendor/ + +.DS_Store +Thumbs.db \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..89280b5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM serversideup/php:8.4-frankenphp-trixie + +USER root + +RUN apt-get update && apt-get install -y --no-install-recommends \ + git \ + unzip \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /var/www/html + +COPY --chown=www-data:www-data composer.json composer.lock* ./ + +RUN composer install \ + --no-interaction \ + --no-progress \ + --prefer-dist \ + --no-dev + +COPY --chown=www-data:www-data . . + +RUN mkdir -p /var/www/html/data \ + && chown -R www-data:www-data /var/www/html + +ENV CADDY_SERVER_ROOT=/var/www/html + +USER www-data + +EXPOSE 8787 \ No newline at end of file diff --git a/README.md b/README.md index fa63c77..5271956 100644 --- a/README.md +++ b/README.md @@ -23,13 +23,22 @@ This is the server and dashboard component of [DebugPHP](https://github.com/Call ## Installation +### Option A — PHP built-in server + ```bash git clone https://github.com/CallMeLeon167/debugphp-server.git cd debugphp-server composer install +php -S localhost:8787 ``` -Then open `http://localhost:8080/setup/` in your browser and follow the setup wizard. +### Option B — Docker + +```bash +git clone https://github.com/CallMeLeon167/debugphp-server.git +cd debugphp-server +docker compose up +``` --- @@ -54,6 +63,16 @@ Debug::send('Hello DebugPHP!'); Debug::send($user, 'User')->color('blue'); ``` +## Running inside Docker? + +Enable auto-detection so the client finds the server automatically: + +```php +Debug::init('your-session-token', [ + 'dockerized' => true, +]); +``` + See the [DebugPHP client repository](https://github.com/CallMeLeon167/debugphp) for the full API documentation. --- diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f8d8a39 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,49 @@ +services: + app: + build: + context: . + dockerfile: Dockerfile + container_name: debugphp-server + hostname: debugphp-server + user: root + ports: + - '8787:8787' + environment: + CADDY_HTTP_PORT: '8787' + volumes: + - ./:/var/www/html:cached + - vendor:/var/www/html/vendor + - data:/var/www/html/data + working_dir: /var/www/html + networks: + - debugphp + restart: unless-stopped + + network-joiner: + image: docker:cli + container_name: debugphp-network-joiner + restart: unless-stopped + depends_on: + - app + volumes: + - /var/run/docker.sock:/var/run/docker.sock + command: > + sh -c ' + echo "[joiner] starting auto-join loop..."; + while true; do + for net in $$(docker network ls --format "{{.Name}}" | grep -Ev "^(bridge|host|none|debugphp)$$"); do + if ! docker network inspect "$$net" --format "{{range .Containers}}{{.Name}} {{end}}" | grep -q "debugphp-server"; then + docker network connect "$$net" debugphp-server 2>/dev/null && echo "[joiner] joined $$net" || true; + fi; + done; + sleep 10; + done + ' + +volumes: + vendor: + data: + +networks: + debugphp: + name: debugphp diff --git a/src/Config.php b/src/Config.php index 60bc1e2..97615c6 100644 --- a/src/Config.php +++ b/src/Config.php @@ -29,7 +29,7 @@ final class Config { /** @var string */ - private string $version = '0.3.2'; + private string $version = '0.4.0'; /** @var self */ private static self $instance;