Lumen ã« Laravel Sail ãã¤ã³ã¹ãã¼ã«ããã¨ãã®ä½æ¥æé ã®ã¡ã¢
æ¤è¨¼ç°å¢
Windows11 Home Edition (version 24H2) D:\>wsl --version WSL ãã¼ã¸ã§ã³: 2.3.26.0 ã«ã¼ãã« ãã¼ã¸ã§ã³: 5.15.167.4-1 WSLg ãã¼ã¸ã§ã³: 1.0.65 MSRDC ãã¼ã¸ã§ã³: 1.2.5620 Direct3D ãã¼ã¸ã§ã³: 1.611.1-81528511 DXCore ãã¼ã¸ã§ã³: 10.0.26100.1-240331-1435.ge-release Windows ãã¼ã¸ã§ã³: 10.0.26100.2605 # installed ubuntu version Ubuntu 22.04.4 LTS (Jammy Jellyfish) # docker Docker version 27.4.1, build b9d17ea Docker Compose version v2.32.1 github.com/docker/buildx v0.19.3 48d6a39
Ubuntu ç°å¢ã« devbox ãã¤ã³ã¹ãã¼ã«
ä¸è¨ã³ãã³ã㧠devbox
ãã¤ã³ã¹ãã¼ã«
$ curl -fsSL https://get.jetify.com/devbox | bash
æ£å¸¸ã«ã¤ã³ã¹ãã¼ã«ãããã確èª
$ devbox version 0.13.7
$ devbox help Instant, easy, predictable development environments Usage: devbox [flags] devbox [command] Available Commands: add Add a new package to your devbox auth Devbox auth commands cache Collection of commands to interact with nix cache completion Generate the autocompletion script for the specified shell create Initialize a directory as a devbox project using a template generate Generate supporting files for your project global Manage global devbox packages help Help about any command info Display package info init Initialize a directory as a devbox project install Install all packages mentioned in devbox.json list List installed packages rm Remove a package from your devbox run Run a script or command in a shell with access to your packages search Search for nix packages secrets Interact with devbox secrets in jetify cloud. services Interact with devbox services. shell Start a new shell with access to your packages shellenv Print shell commands that create a Devbox Environment in the shell update Update packages in your devbox version Print version information Flags: -h, --help help for devbox -q, --quiet suppresses logs Use "devbox [command] --help" for more information about a command.
Lumen ã®ããã¸ã§ã¯ããä½æ
Lumen ããã¸ã§ã¯ãã®ãã£ã¬ã¯ããªãä½æã㦠php
㨠composer
ãã¤ã³ã¹ãã¼ã«
$ mkdir lumen-project $ cd lumen-project $ devbox init $ devbox add php82 php82Packages.composer
composer
ã使ã£ã¦ Lumen ãã¤ã³ã¹ãã¼ã«
$ devbox shell (devbox) $ composer create-project laravel/lumen ./tmp (devbox) $ mv ./tmp/* ./tmp/.* . (devbox) $ rmdir ./tmp (devbox) $ php artisan --version Laravel Framework Lumen (10.0.4) (Laravel Components ^10.0)
Laravel Sail ã®ã¤ã³ã¹ãã¼ã«
composer
ã使ã£ã¦ Laravel Sail ãã¤ã³ã¹ãã¼ã«
(devbox) $ composer require laravel/sail --dev
boostrap/app.php
ã«ä¸è¨ã追å
if(env('APP_ENV') == 'local')
{
$app->register(Laravel\Sail\SailServiceProvider::class);
}
sail
é¢é£ã® artisan
ã³ãã³ãã追å ããã¦ããã確èª
(devbox) $ php artisan list . . . sail sail:add Add a service to an existing Sail installation sail:install Install Laravel Sail's default Docker Compose file sail:publish Publish the Laravel Sail Docker files . . .
php artisan sail:install
ãå®è¡ãã
(devbox) $ php artisan sail:install --devcontainer
Laravel Sail ã®ã«ã¹ã¿ãã¤ãº
ã¤ã³ã¹ãã¼ã«ç´å¾ã®ç¶æ ã§ã¯ HTTP ãµã¼ãã¼ãèµ·åããªãããã«ã¹ã¿ãã¤ãºãè¡ã
docker-compose.yml
laravel.test
ã® environment
ã« SUPERVISOR_PHP_COMMAND
ã追å
--- a/docker-compose.yml 2025-01-02 17:27:54.006158767 +0900 +++ b/docker-compose.yml 2025-01-02 17:14:04.886161856 +0900 @@ -17,6 +17,7 @@ XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}' XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}' IGNITION_LOCAL_SITES_PATH: '${PWD}' + SUPERVISOR_PHP_COMMAND: "/usr/bin/php -d variables_order=EGPCS -S 0.0.0.0:80 -t /var/www/html/public" volumes: - '.:/var/www/html' networks:
.env
WWWGROUP
㨠WWWUSER
ã追å
WWWGROUP=1000 WWWUSER=1000
åä½ç¢ºèª
ä¸è¨ã³ãã³ã㧠sail
ãç«ã¡ä¸ãã
$ ./vendor/bin/sail up -d
http://localhost ã«ã¢ã¯ã»ã¹ãã¦ä»¥ä¸ã®ã¬ã¹ãã³ã¹ãè¿ãã°æå
Lumen (10.0.4) (Laravel Components ^10.0)
ãã©ãã«ã·ã¥ã¼ãã£ã³ã°
artisan sail:publish
ãåä½ããªã
artisan sail:publish
ã¯å
é¨ã§ artisan vendor:publish
ãå¼ã³åºãã¦ãããã Lumen ã§ã¯åä½ããªã
ä¸è¨æé 㧠artisna sail:publish
ã¨åãçµæãå¾ããã
vendor/laravel/sail/
以ä¸ã® docker é¢é£ãã¡ã¤ã«ã ./docker/
以ä¸ã¸ã³ãã¼
$ mkdir ./docker $ cp -rf ./vendor/laravel/sail/runtimes/* ./docker/ $ cp -rf ./vendor/laravel/sail/database/* ./docker/
å¿
è¦ã«å¿ã㦠docker-compose.yml
ã® context
ãªã©ã®ãã¹æå®ãå¤æ´ãã
--- a/docker-compose.yml 2025-01-02 18:36:41.176152586 +0900 +++ b/docker-compose.yml 2025-01-02 18:37:11.586153133 +0900 @@ -1,7 +1,7 @@ services: laravel.test: build: - context: './vendor/laravel/sail/runtimes/8.4' + context: './docker/8.4' dockerfile: Dockerfile args: WWWGROUP: '${WWWGROUP}'