### Install Laravel dependencies and run dev server Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/README.md Enter the workspace container and install Laravel dependencies with Composer and npm, then start the development server with npm run dev. ```bash docker compose -f compose.dev.yaml exec workspace bash composer install npm install npm run dev ``` -------------------------------- ### Start the development stack Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/compose-dev.md Copies the .env.example file to .env, starts the stack in detached mode, and opens a bash shell in the workspace container. Inside the container, install Composer and npm dependencies and run the dev server. ```bash cp .env.example .env docker compose -f compose.dev.yaml up -d docker compose -f compose.dev.yaml exec workspace bash # inside the workspace container: composer install && npm install && npm run dev ``` -------------------------------- ### Clone the repository Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/README.md Clone the Laravel Docker Examples repository and navigate into the project directory. ```bash git clone https://github.com/rw4lll/laravel-docker-examples.git cd laravel-docker-examples ``` -------------------------------- ### Common workspace commands Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/workspace-image.md Typical commands run inside the workspace container. composer install and npm install install dependencies; npm run dev starts Vite on port 5173; php artisan migrate runs migrations; node -v shows the NVM-installed Node version. ```bash composer install npm install npm run dev # starts Vite, reachable on host at http://localhost:5173 php artisan migrate node -v # v22.x (per default NODE_VERSION=22.0.0) ``` -------------------------------- ### Run production container with default CMD Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/entrypoints.md Starts the production container with the default CMD `php-fpm`, mapping port 9000 and loading environment variables from `.env`. ```bash docker run --rm -p 9000:9000 --env-file .env laravel-app:prod ``` -------------------------------- ### Check Docker and Docker Compose versions Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/README.md Verify that Docker and Docker Compose are installed. If these commands do not return the versions, install Docker and Docker Compose using the official documentation. ```bash docker --version docker compose version ``` -------------------------------- ### GET / Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/endpoints.md Returns the welcome page. Logs a message when visited. ```APIDOC ## GET / ### Description Returns the welcome page. Logs a message when visited. ### Method GET ### Endpoint / ### Parameters None ### Request Body None ### Response - Status: 200 OK - Content-Type: text/html - Body: rendered resources/views/welcome.blade.php ### Side Effects - Log::info('Welcome page visited') written to the default log channel ### Authentication None ``` -------------------------------- ### Start Docker Compose services Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/README.md Start the Docker Compose services defined in compose.dev.yaml in detached mode. ```bash docker compose -f compose.dev.yaml up -d ``` -------------------------------- ### GET / route handler in routes/web.php Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/endpoints.md Defines the GET / route in routes/web.php. Logs a message and returns the welcome view. No authentication or middleware is applied. ```php Route::get('/', function () { Log::info('Welcome page visited'); return view('welcome'); }); ``` -------------------------------- ### Example /health response with a failed dependency Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/errors.md Shows the JSON body returned by GET /health when at least one dependency probe fails, resulting in HTTP 503. The example shows the database and storage probes OK, but redis in Error state. ```json {"database":"OK","redis":"Error","storage":"OK"} ``` -------------------------------- ### Deploy production stack with docker compose Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/compose-prod.md Copies the environment file, sets required variables, and starts the production stack in detached mode. Then verifies all services are healthy. ```bash cp .env.example .env export NGINX_PORT=8080 POSTGRES_PASSWORD='a-strong-secret' docker compose -f compose.prod.yaml up -d --build docker compose -f compose.prod.yaml ps # all services shown healthy ``` -------------------------------- ### Extending AppServiceProvider to wire services Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/service-layer.md Example of extending the provider to register a singleton binding for PaymentGateway and schedule the 'inspire' command hourly. Shows the documented pattern for wiring application services. ```php app->singleton(PaymentGateway::class, StripeGateway::class); } public function boot(): void { \Illuminate\Support\Facades\Schedule::command('inspire')->hourly(); } } ``` -------------------------------- ### GET /info route handler in routes/web.php Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/endpoints.md Defines the GET /info route in routes/web.php. Logs a message and outputs phpinfo() HTML. Exposes full PHP/extension configuration; the README lock-down does not disable it. ```php Route::get('/info', function () { Log::info('Phpinfo page visited'); return phpinfo(); }); ``` -------------------------------- ### GET /info Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/endpoints.md Returns PHP configuration information via phpinfo(). Logs a message when visited. ```APIDOC ## GET /info ### Description Returns PHP configuration information via phpinfo(). Logs a message when visited. ### Method GET ### Endpoint /info ### Parameters None ### Request Body None ### Response - Status: 200 OK - Content-Type: text/html - Body: output of phpinfo() with PHP_INI_ALL configuration details ### Side Effects - Log::info('Phpinfo page visited') ### Authentication None ### Security Note Exposes full PHP/extension configuration; README-recommended lock-down does not disable it. ``` -------------------------------- ### GET /up Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/endpoints.md Framework-provided health route registered in bootstrap/app.php. ```APIDOC ## GET /up ### Description Framework-provided health route registered in bootstrap/app.php. ### Method GET ### Endpoint /up ### Parameters None ### Request Body None ### Response - Status: 200 OK (if healthy) - Content-Type: application/json - Body: health status ### Authentication None ``` -------------------------------- ### Development entrypoint.sh for PHP-FPM Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/entrypoints.md Development entrypoint script that clears cached config, routes, and views to avoid caching issues, then executes the container command. It aborts on first failure and ends with `exec "$@"` to start php-fpm or a passed command like bash. ```sh #!/bin/sh set -e # Clear configurations to avoid caching issues in development echo "Clearing configurations..." php artisan config:clear php artisan route:clear php artisan view:clear # Run the default command (e.g., php-fpm or bash) exec "$@" ``` -------------------------------- ### Rebuild containers Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/README.md Rebuild and start the Docker Compose services in detached mode. ```bash docker compose -f compose.dev.yaml up -d --build ``` -------------------------------- ### User model usage example Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/user-model.md Shows how to create a user with mass assignment, use the Notifiable and HasFactory traits, and access cast attributes. The password is stored bcrypt-hashed via the 'hashed' cast. JSON serialization excludes password and remember_token. ```php use App\Models\User; // create (mass assignment filtered by $fillable) $user = User::create([ 'name' => 'Ada', 'email' => 'ada@example.com', 'password' => 'secret123', // stored bcrypt-hashed via 'hashed' cast ]); // public API surface: traits + inherited Authenticatable methods $user->notify(new \App\Notifications\Welcome()); // Notifiable trait User::factory()->count(10)->create(); // HasFactory trait echo $user->email_verified_at; // Carbon|null (datetime cast) echo json_encode($user); // excludes password & remember_token ``` -------------------------------- ### GET /up Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/endpoints.md Framework health route registered via health: '/up' in bootstrap/app.php. The handler is provided by the framework and its response body and status semantics are not defined in the repository. ```APIDOC ## GET /up ### Description Framework health route registered via `health: '/up'` in `bootstrap/app.php`. The handler is provided by the framework (`Illuminate\Foundation\Configuration\ApplicationBuilder`); its response body and exact status semantics are not defined in this repository's source. ### Method GET ### Endpoint /up ``` -------------------------------- ### Usage commands for artisan and health route Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/bootstrap.md Shows example commands for the artisan CLI and a curl request to the health route. The route:list command displays the routes /, /info, /health, /up. The curl command expects a 200 response from the framework health route. ```bash php artisan inspire # console command (see endpoints.md) php artisan route:list # shows: /, /info, /health, /up curl http://localhost/up # 200 from framework health route ``` -------------------------------- ### curl example calls for /health Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/endpoints.md Shows how to call the /health endpoint. The first command returns the JSON status; the second prints only the HTTP status code. The expected output for a healthy system is shown as a comment. ```bash curl -s http://localhost/health # {"database":"OK","redis":"OK","storage":"OK"} curl -s -o /dev/null -w '%{http_code}\n' http://localhost/health # 200 ``` -------------------------------- ### Observability commands for container health Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/errors.md Bash commands to inspect container status and logs for the php-fpm service in the production Compose setup. Use these to diagnose entrypoint failures and container health. ```bash docker compose -f compose.prod.yaml ps # unhealthy status per service docker compose -f compose.prod.yaml logs -f php-fpm docker inspect --format '{{.State.Health.Status}}' ``` -------------------------------- ### PHP-FPM development stage build arguments Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/php-fpm-image.md Declares build arguments in the development stage of the PHP-FPM Dockerfile. These control Xdebug installation and configuration, and the UID/GID used to create the www user. ```dockerfile ARG XDEBUG_ENABLED=true ARG XDEBUG_MODE=develop,coverage,debug,profile ARG XDEBUG_HOST=host.docker.internal ARG XDEBUG_IDE_KEY=DOCKER ARG XDEBUG_LOG=/dev/stdout ARG XDEBUG_LOG_LEVEL=0 ARG UID=1000 ARG GID=1000 ``` -------------------------------- ### Workspace Dockerfile build arguments Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/workspace-image.md Declares the build arguments with defaults for the workspace image. UID and GID set the host user and group for the www user; NODE_VERSION is the Node.js version installed by NVM and set as the default alias. ```dockerfile ARG UID=1000 ARG GID=1000 ARG NODE_VERSION=22.0.0 ``` -------------------------------- ### boot() method signature Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/service-layer.md Empty method that bootstraps no services. Invoked after all providers have registered, when the container is ready. ```php public function boot(): void ``` -------------------------------- ### Manually run production entrypoint and inspect cache Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/entrypoints.md Drives production startup manually for debugging by overriding the entrypoint to /bin/sh, running entrypoint.sh, and listing the cache artifacts. ```bash docker run --rm --entrypoint /bin/sh laravel-app:prod -c \ "entrypoint.sh && ls -la /var/www/bootstrap/cache/" ``` -------------------------------- ### Run and list the 'inspire' command Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/endpoints.md Shows how to run the 'inspire' command and verify it appears in the Artisan command list. ```bash php artisan inspire php artisan list | grep inspire ``` -------------------------------- ### Build and run workspace image directly Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/workspace-image.md Builds and runs the workspace image directly, mounting the current directory to /var/www and exposing port 5173 for Vite. Requires a mounted application tree. ```bash docker build -f docker/development/workspace/Dockerfile \ --build-arg UID=$(id -u) --build-arg GID=$(id -g) \ -t laravel-workspace . docker run --rm -it -v "$PWD:/var/www" -p 5173:5173 laravel-workspace ``` -------------------------------- ### Copy .env.example to .env Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/README.md Copy the .env.example file to .env. Adjust the UID and GID variables in the .env file to match your user ID and group ID, which you can find by running `id -u` and `id -g` in the terminal. ```bash cp .env.example .env ``` -------------------------------- ### Create users, password_reset_tokens, and sessions tables Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/database-layer.md Migration up() method that creates the users, password_reset_tokens, and sessions tables. The users table includes id, name, unique email, nullable email_verified_at, password, rememberToken, and timestamps. The password_reset_tokens table uses email as primary key. The sessions table includes id, user_id foreign key, ip_address, user_agent, payload, and last_activity. ```php public function up(): void { Schema::create('users', function (Blueprint $table) { $table->id(); $table->string('name'); $table->string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); $table->rememberToken(); $table->timestamps(); }); Schema::create('password_reset_tokens', function (Blueprint $table) { $table->string('email')->primary(); $table->string('token'); $table->timestamp('created_at')->nullable(); }); Schema::create('sessions', function (Blueprint $table) { $table->string('id')->primary(); $table->foreignId('user_id')->nullable()->index(); $table->string('ip_address', 45)->nullable(); $table->text('user_agent')->nullable(); $table->longText('payload'); $table->integer('last_activity')->index(); }); } ``` -------------------------------- ### Production entrypoint.sh for PHP-FPM Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/entrypoints.md Production entrypoint script that initializes storage, runs migrations, caches config and routes, then executes the container command. It aborts on any failing command due to `set -e` and ends with `exec "$@"` to replace the shell with the image CMD. ```sh #!/bin/sh set -e # Initialize storage directory if empty # ----------------------------------------------------------- # If the storage directory is empty, copy the initial contents # and set the correct permissions. # ----------------------------------------------------------- if [ ! "$(ls -A /var/www/storage)" ]; then echo "Initializing storage directory..." cp -R /var/www/storage-init/. /var/www/storage chown -R www-data:www-data /var/www/storage fi # Remove storage-init directory rm -rf /var/www/storage-init # Run Laravel migrations # ----------------------------------------------------------- # Ensure the database schema is up to date. # ----------------------------------------------------------- php artisan migrate --force # Clear and cache configurations # ----------------------------------------------------------- # Improves performance by caching config and routes. # ----------------------------------------------------------- php artisan config:cache php artisan route:cache # Run the default command exec "$@" ``` -------------------------------- ### GET /health Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/endpoints.md Returns a JSON status indicating health. Returns 200 or 503. ```APIDOC ## GET /health ### Description Returns a JSON status indicating health. Returns 200 or 503. ### Method GET ### Endpoint /health ### Parameters None ### Request Body None ### Response - Status: 200 OK or 503 Service Unavailable - Content-Type: application/json - Body: JSON status object ### Authentication None ``` -------------------------------- ### Copy storage directory to storage-init Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/php-fpm-image.md Copies the storage directory to /var/www/storage-init, which the production entrypoint uses as the seed for an empty /var/www/storage. ```dockerfile COPY ./storage /var/www/storage-init ``` -------------------------------- ### public/index.php HTTP entry point Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/bootstrap.md Handles HTTP requests arriving via Nginx → PHP-FPM. Sets LARAVEL_START timestamp, checks maintenance mode, loads Composer autoloader, bootstraps the application, and handles the request with Request::capture(). ```php handleRequest(Request::capture()); ``` -------------------------------- ### GET /health Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/endpoints.md Probes database, Redis, and storage dependencies. Returns a JSON object with the status of each dependency and an HTTP status code of 200 if all are OK, or 503 if any are in error. ```APIDOC ## GET /health ### Description Probes database, Redis, and storage dependencies. Returns a JSON object with the status of each dependency and an HTTP status code of 200 if all are OK, or 503 if any are in error. ### Method GET ### Endpoint /health ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Response #### Response Schema | Field | Type | Values | Description | |---|---|---|---| | `database` | `string` | `OK` \| `Error` | `OK` if database connection and query succeed; else `Error` | | `redis` | `string` | `OK` \| `Error` | `OK` if Redis cache store read/write succeeds; else `Error` | | `storage` | `string` | `OK` \| `Error` | `OK` if storage file round-trip succeeds; else `Error` | #### Response Example ```json {"database":"OK","redis":"OK","storage":"OK"} ``` ### Status Codes | Code | Condition | |---|---| | `200` | All probes returned `OK` | | `503` | At least one probe returned `Error` | ### Side Effects - Redis: writes and expires `health_check` key with TTL 10 seconds. - Storage: creates and deletes `health_check.txt` on the default disk. ### Example Calls ```bash curl -s http://localhost/health # {"database":"OK","redis":"OK","storage":"OK"} curl -s -o /dev/null -w '%{http_code}\n' http://localhost/health # 200 ``` ``` -------------------------------- ### View logs for all services Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/README.md View and follow logs for all services. ```bash docker compose -f compose.dev.yaml logs -f ``` -------------------------------- ### Build and run production PHP-FPM image Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/php-fpm-image.md Builds the production PHP-FPM image and runs it as a container, mapping port 9000 and loading environment variables from .env. The image target is 'production' and the resulting tag is 'laravel-app:prod'. ```bash docker build -f docker/common/php-fpm/Dockerfile --target production -t laravel-app:prod . docker run --rm -p 9000:9000 --env-file .env laravel-app:prod ``` -------------------------------- ### Consumer code for checking /health status Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/errors.md PHP example using Laravel's Http facade to call the /health endpoint. If the response status is 503, it decodes the JSON body and iterates over each dependency state, alerting on any that are not 'OK'. ```php use Illuminate\Support\Facades\Http; $res = Http::get('http://localhost/health'); if ($res->status() === 503) { $status = $res->json(); // ['database' => 'OK', 'redis' => 'Error', ...] foreach ($status as $dep => $state) { if ($state !== 'OK') { // alert on: database | redis | storage } } } ``` -------------------------------- ### artisan CLI entry point Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/bootstrap.md Handles CLI commands. Sets LARAVEL_START timestamp, loads Composer autoloader, bootstraps the application, and handles the command with ArgvInput. The exit code of handleCommand becomes the process exit status. ```php #!/usr/bin/env php handleCommand(new ArgvInput); exit($status); ``` -------------------------------- ### Run Laravel migrations Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/README.md Run database migrations inside the workspace container using Artisan. ```bash docker compose -f compose.dev.yaml exec workspace php artisan migrate ``` -------------------------------- ### Laravel /health route handler (routes/web.php:15-66) Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/endpoints.md Defines the GET /health route. It checks database connectivity via DB::connection()->getPdo() and DB::select('SELECT 1'), Redis via Cache::store('redis')->put/get with TTL 10, and storage via Storage::put/get/delete of health_check.txt. Returns JSON with per-dependency status and HTTP 200 if all OK, else 503. ```php Route::get('/health', function () { $status = []; // Check Database Connection try { DB::connection()->getPdo(); // Optionally, run a simple query DB::select('SELECT 1'); $status['database'] = 'OK'; } catch (\Exception $e) { $status['database'] = 'Error'; } // Check Redis Connection try { Cache::store('redis')->put('health_check', 'OK', 10); $value = Cache::store('redis')->get('health_check'); if ($value === 'OK') { $status['redis'] = 'OK'; } else { $status['redis'] = 'Error'; } } catch (\Exception $e) { $status['redis'] = 'Error'; } // Check Storage Access try { $testFile = 'health_check.txt'; Storage::put($testFile, 'OK'); $content = Storage::get($testFile); Storage::delete($testFile); if ($content === 'OK') { $status['storage'] = 'OK'; } else { $status['storage'] = 'Error'; } } catch (\Exception $e) { $status['storage'] = 'Error'; } // Determine overall health status $isHealthy = collect($status)->every(function ($value) { return $value === 'OK'; }); $httpStatus = $isHealthy ? 200 : 503; return response()->json($status, $httpStatus); }); ``` -------------------------------- ### Build development PHP-FPM image with host-user sync Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/php-fpm-image.md Builds the development target of the PHP-FPM image with host-user sync by passing the current user's UID and GID as build arguments, tagging the image as 'laravel-app:dev'. ```bash docker build -f docker/common/php-fpm/Dockerfile \ --target development \ --build-arg UID=$(id -u) --build-arg GID=$(id -g) \ -t laravel-app:dev . ``` -------------------------------- ### Build and run production Nginx image Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/nginx-image.md Builds the production Nginx image and runs it with read-only volumes for storage and built assets. The container listens on port 8080 and maps to port 80 inside. ```bash docker build -f docker/production/nginx/Dockerfile -t laravel-web:prod . docker run --rm -p 8080:80 -v laravel-storage-production:/var/www/storage:ro \ -v laravel-public-assets:/var/www/public/build:ro laravel-web:prod ``` -------------------------------- ### Clone the forked repository Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/README.md Clones the forked repository and navigates into the project directory. ```bash git clone https://github.com/your-user-name/laravel-docker-examples.git cd laravel-docker-examples ``` -------------------------------- ### register() method signature Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/service-layer.md Empty method that registers no container bindings. Invoked during framework bootstrap for every provider in bootstrap/providers.php. ```php public function register(): void ``` -------------------------------- ### Create a feature branch Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/README.md Creates and switches to a new branch for your feature work. ```bash git checkout -b your-feature-branch ``` -------------------------------- ### bootstrap/app.php application factory Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/bootstrap.md Configures the Laravel application with routing, middleware, and exception handling. Registers web routes from routes/web.php, console commands from routes/console.php, and a health route at '/up'. The withMiddleware and withExceptions closures are currently empty extension points. ```php withRouting( web: __DIR__.'/../routes/web.php', commands: __DIR__.'/../routes/console.php', health: '/up', ) ->withMiddleware(function (Middleware $middleware) { // }) ->withExceptions(function (Exceptions $exceptions) { // })->create(); ``` -------------------------------- ### View logs for a specific service Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/README.md View and follow logs for a specific service, such as the web service. ```bash docker compose -f compose.dev.yaml logs -f web ``` -------------------------------- ### Enable FPM status path at /status Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/php-fpm-image.md Full content of docker/common/php-fpm/conf.d/20-status-path.conf. Enables the FPM status endpoint at pool path /status, which the php-fpm-healthcheck binary probes over FastCGI. ```ini [www] pm.status_path = /status ``` -------------------------------- ### DatabaseSeeder run() method Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/database-layer.md DatabaseSeeder run() method creates exactly one user named 'Test User' with email 'test@example.com'. The commented line shows the scaling variant to create ten users. ```php class DatabaseSeeder extends Seeder { public function run(): void { // User::factory(10)->create(); User::factory()->create([ 'name' => 'Test User', 'email' => 'test@example.com', ]); } } ``` -------------------------------- ### Run Laravel migrations and seeders Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/database-layer.md Commands to run database migrations and seeders in a Laravel application. Use `migrate` to apply all migrations, `migrate:fresh --seed` to reset the schema and then seed, and `db:seed --class=DatabaseSeeder` to run a specific seeder class. ```bash php artisan migrate # apply all migrations php artisan migrate:fresh --seed # reset schema, then seed php artisan db:seed --class=DatabaseSeeder ``` -------------------------------- ### Console command: inspire Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/endpoints.md Artisan console command that displays an inspiring quote. It takes no arguments or options and prints the quote via the comment method. ```APIDOC ## Console command: inspire ### Description Artisan console command that displays an inspiring quote. It takes no arguments or options and prints the quote via the comment method. ### Signature `inspire` (no arguments, no options) ### Purpose Display an inspiring quote ### Behavior Prints `Inspiring::quote()` via `$this->comment(...)` (green console text) ### Exit Code `0` on success (Artisan default) ### Usage ```bash php artisan inspire php artisan list | grep inspire ``` ``` -------------------------------- ### Enter workspace container Source: https://github.com/dockersamples/laravel-docker-examples/blob/main/_autodocs/api-reference/workspace-image.md Opens a login shell in the workspace service. The login shell sources the NVM bashrc hooks, making npm and node available. ```bash docker compose -f compose.dev.yaml exec workspace bash ```