Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Db Ready

Laravel Db Ready Laravel Package

mll-lab/laravel-db-ready

mll-lab/laravel-db-ready adds an Artisan command that waits until your database accepts connections, retrying with configurable timeouts. Handy in Docker entrypoints and CI pipelines where migrations run before MySQL or Postgres is fully up, so boot scripts avoid race conditions.

View on GitHub
Deep Wiki
Context7

An artisan command to check if a database connection is ready

Frequently asked questions about Laravel Db Ready
How do I install mll-lab/laravel-db-ready in a Laravel app?
Install it with Composer using composer require mll-lab/laravel-db-ready. For v4, your application should run Laravel 9 on PHP 8.0.2 or newer; Laravel 8 may work only if the Composer constraints resolve. After installation, the db:wait Artisan command is available without extra configuration for typical setups.
What does the db:wait Artisan command do?
It blocks until the configured database connection accepts connections, polling at a retry interval until a timeout is reached. On success it exits zero; on failure it exits non-zero so Docker, Kubernetes, or CI can react. It replaces ad hoc retry loops in entrypoint scripts.
Which Laravel and PHP versions does mll-lab/laravel-db-ready support?
Version 4 targets Laravel 9 and PHP 8.0.2 or newer. It drops Laravel 6 and 7 as well as PHP 7.3, so older applications need a platform upgrade before adopting v4. Laravel 8 support should be verified against the installed release's composer.json constraints rather than assumed.
How do I use db:wait in a Docker Compose entrypoint?
Add php artisan db:wait to your container entrypoint before running migrations or starting the app server. The command will block until the configured database connection is reachable or the timeout expires. Because it returns a non-zero exit code on failure, the container can fail fast instead of starting in a broken state.
Can I wait for a specific database connection instead of the default one?
Yes. The command polls the default connection by default but can be pointed at a specified database connection. This is useful when your app defines multiple connections, such as a primary database plus a separate reporting or tenant database.
How do I configure the timeout and retry interval for db:wait?
The package exposes configurable timeout and retry interval settings for the wait operation. Run php artisan db:wait --help to see the exact options supported by your installed version. Set the timeout to match your orchestration platform's startup budget and healthcheck thresholds.
Does mll-lab/laravel-db-ready work with MySQL, PostgreSQL, and SQLite?
Yes. It uses Laravel's database connection layer, so it works with any Laravel-supported driver, including MySQL, PostgreSQL, and SQLite. That makes it suitable for local Docker Compose setups as well as production Kubernetes deployments.
How is db:wait different from wait-for-it or dockerize?
wait-for-it and dockerize test host and port reachability from the shell, while db:wait asks Laravel to connect using your application's database configuration. That means credentials, connection names, and driver-specific behavior are already applied. The command also returns clean exit codes for shell scripts and healthchecks, avoiding scattered retry logic in entrypoints.
How do I upgrade from v3 to v4 of mll-lab/laravel-db-ready?
v4 is a breaking release that changes the support matrix to Laravel 9 and PHP 8.0.2+. Upgrade PHP and Laravel first, then run composer why-not mll-lab/laravel-db-ready v4 to identify conflicts before updating the package. Test the application and any entrypoint scripts in a branch and update CI matrices before deploying.
Can I use db:wait in Kubernetes init containers or CI pipelines?
Yes. Run php artisan db:wait in a Kubernetes init container or as a CI setup step before migrations or tests. The command blocks until the database is reachable and exits non-zero on timeout, which lets the init container or CI job fail clearly. This avoids race conditions when the database pod or service starts after the application.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource