feat(preflight): add an initial preflight check#988
Conversation
270d470 to
df069eb
Compare
There was a problem hiding this comment.
Pull request overview
Adds a standalone “preflight” CLI command to validate a LibreBooking installation’s runtime prerequisites (PHP environment, filesystem, config, and database reachability) before or during setup.
Changes:
- Introduces
lib/preflight.phprunner with checks for PHP version/extensions, composer deps, config validity, writable dirs, and DB connectivity/schema presence. - Adds
composer preflightscript entry and documents the preflight workflow in installation docs. - Updates published requirements to move
bcmathto optional and clarify required/optional PHP extensions.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| lib/preflight.php | New standalone preflight checker and CLI entrypoint. |
| docs/source/INSTALLATION.rst | Documents preflight usage and updates composer install guidance. |
| composer.json | Adds preflight composer script. |
| README.md | Updates required/optional PHP extension lists. |
Comments suppressed due to low confidence (1)
docs/source/INSTALLATION.rst:60
- The installation instructions now use
composer installwithout--no-dev. For production installs this will pull in dev-only tooling (phpunit/phpstan/phpcs), increasing install time and potentially widening the dependency surface without providing runtime value. Consider restoring guidance to usecomposer install --no-devfor deployments (and mention plaincomposer installonly for contributors).
.. code-block:: bash
cd librebooking
# Install without the developer dependencies
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
df069eb to
49612c0
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lib/preflight.php
Outdated
| $config = @include $configPath; | ||
|
|
||
| if (!is_array($config)) { | ||
| return new CheckResult( | ||
| status: CheckStatus::Fail, | ||
| label: 'Configuration file: config/config.php did not return a valid array', | ||
| message: "Ensure the file returns an array with a 'settings' key. See config/config.dist.php for reference.", |
There was a problem hiding this comment.
@include $configPath suppresses parse/runtime warnings from config.php, which can make it hard to diagnose why the config is considered invalid. Consider checking is_readable($configPath) and/or surfacing the underlying include error (e.g., capture error_get_last()) in the failure message.
| $config = @include $configPath; | |
| if (!is_array($config)) { | |
| return new CheckResult( | |
| status: CheckStatus::Fail, | |
| label: 'Configuration file: config/config.php did not return a valid array', | |
| message: "Ensure the file returns an array with a 'settings' key. See config/config.dist.php for reference.", | |
| if (!is_readable($configPath)) { | |
| return new CheckResult( | |
| status: CheckStatus::Fail, | |
| label: 'Configuration file: config/config.php is not readable', | |
| message: "The configuration file at '{$configPath}' exists but is not readable. Check file permissions and ownership.", | |
| ); | |
| } | |
| $previousError = error_get_last(); | |
| $config = include $configPath; | |
| $lastError = error_get_last(); | |
| $includeErrorMessage = null; | |
| if ($lastError !== null && $lastError !== $previousError) { | |
| $includeErrorMessage = $lastError['message'] ?? null; | |
| } | |
| if (!is_array($config)) { | |
| $message = "Ensure the file returns an array with a 'settings' key. See config/config.dist.php for reference."; | |
| if ($includeErrorMessage !== null) { | |
| $message .= " Last PHP error while including config.php: {$includeErrorMessage}"; | |
| } | |
| return new CheckResult( | |
| status: CheckStatus::Fail, | |
| label: 'Configuration file: config/config.php did not return a valid array', | |
| message: $message, |
49612c0 to
c260299
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ea6810d to
af64d0d
Compare
Add `composer preflight` command that validates PHP version, extensions, configuration, writable directories, and database connectivity. Move bcmath from required to optional extensions (only needed for Active Directory authentication). Database failures are reported as failures/warnings with guidance to run the installer at http://<your-server>/Web/install/.
af64d0d to
2fd8070
Compare
Add
composer preflightcommand that validates PHP version, extensions, configuration, writable directories, and database connectivity. Move bcmath from required to optional extensions (only needed for Active Directory authentication). Database failures are reported as warnings with guidance to run the installer at http:///Web/install/.