Download the PHP package kirschbaum-development/laravel-preflight-checks without Composer
On this page you can find all versions of the php package kirschbaum-development/laravel-preflight-checks. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kirschbaum-development/laravel-preflight-checks
More information about kirschbaum-development/laravel-preflight-checks
Files in kirschbaum-development/laravel-preflight-checks
Package laravel-preflight-checks
Short Description Preflight Checklist before deployment or development
License MIT
Homepage https://github.com/kirschbaum-development/laravel-preflight-checks
Informations about the package laravel-preflight-checks
Laravel Preflight Checks
Performs pre-flight checks to ensure configuration and setup for deployment or development.
This package is particularly useful for automated deployments where configuration is managed separately (such as containerized deployments via Docker, K8s, etc). It can also be used as a go/no-go check for setting up local and/or dev environments.
Installation
You can install the package via composer:
Setup
After requiring the composer package, publish the config file
Configure the config/preflight_checks.php
file with the configuration necessary for your app. Some defaults are provided (commented out) based on typical environments.
The config file is structured like so: 'checks'
> environment name
> array of checks
Every check can be specified with options, for example:
Or with the fully explicit syntax:
If you need to repeat checks (for example, when using multiple database connections), you will need to use the full syntax.
Available Checks
Database
Kirschbaum\PreflightChecks\Checks\Database
Checks that the database connection can be established, via the PDO, and that the required config keys are set. It outputs some server info and version information.
Option | Description |
---|---|
connection |
The name of the connection in config/database.php |
Redis
Kirschbaum\PreflightChecks\Checks\Redis
Checks that Redis connection can be established, and that the required config keys are set.
Option | Description | |
---|---|---|
connection |
The name of the connection in config/database.php |
) |
Configuration
Kirschbaum\PreflightChecks\Checks\Configuration
Checks that the specified config keys are set. This checks the config
values, NOT the env
values to ensure that in higher environments the correct detection is taking place. As such, make sure to specify the same keys you'd use for config(...)
.
The accepted options for the Configuration
preflight check is a list of config keys to check. For example:
You may also pass a hint (recommended for local development only) that will be shown if the key is not set. For example:
When a new dev sets up their environment and is missing that config value, they will get that nice friendly message helping them find the key.
You can also specify optional config values and provide a hint as well with the OptionalConfiguration
class, which operates the same way, but does not cause the command to fail.
Write Your Own!
If you have a special startup consideration you'd like to make, feel free write your own check, extending Kirschbaum\PreflightChecks\Checks\PreflightCheck
.
Specify any necessary config keys on the $requiredConfig
property.
Implement the check
method, which should perform your check and mark the $result
as pass/fail.
Example:
Usage
Basic usage is via the Artisan command:
If you would like to see the info on successful checks (not just the failures), add a verbose flag -v
.
You may test other environment by specifying the artisan environment (--env
).
For higher and/or automated environments (such as CI/CD), you may want to use the --show-only-failures
flag to cut down on noise.
Kubernetes
In Kubernetes deployments, this can be used in a startup probe (1.20+):
You could also set this up for a readiness probe, but keep in mind that probe is still run throughout the entire lifecycle of the container (we are establishing connections to Redis or the DB, which are not insignificant to consider).
Containerized Environments
In containerized environments (including K8s), you may want to "block" container startup (e.g. php-fpm
) with this command, to ensure the correct environment was loaded and cached properly. For the standard php-fpm
docker container, you can use a startup script such as:
Local Environment
The preflight:check
command can also provide a concrete method of assuring all the appropriate environment configuration has taken place. This can be especially helpful when bringing on new developers, as simply running php artisan preflight:check
can give them a good indication of what's left to setup/configure before their environment is live.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] or [email protected] instead of using the issue tracker.
Credits
Sponsorship
Development of this package is sponsored by Kirschbaum Development Group, a developer driven company focused on problem solving, team building, and community. Learn more about us or join us!
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-preflight-checks with dependencies
illuminate/support Version ^8.0|^9.0|^10.0|^11.0
illuminate/pipeline Version ^8.0|^9.0|^10.0|^11.0