- Can I use craftcms/server-check to validate server requirements for a Laravel app that integrates with Craft CMS?
- Yes, this package is designed to check server configurations specifically for Craft CMS, which is useful if your Laravel app interacts with Craft CMS plugins, shared hosting, or requires Craft-specific PHP extensions like `intl` or `gd`. It ensures compatibility beyond Laravel’s native checks.
- How do I install craftcms/server-check in a Laravel project?
- Run `composer require craftcms/server-check` in your project directory. For development-only checks, add it to the `require-dev` section of your `composer.json`. The package provides a CLI tool (`./vendor/bin/server-check`) and a PHP API for programmatic validation.
- Will this package work with Laravel 10+ and PHP 8.1+?
- Yes, the package supports PHP 8.1+ and is compatible with Laravel 10+. Since it has no direct Laravel dependencies, it integrates cleanly without version conflicts. Always verify your specific Laravel version’s PHP requirements against Craft CMS’s constraints.
- Can I run server checks in a CI/CD pipeline like GitHub Actions?
- Absolutely. The package outputs structured validation results (JSON/array), making it easy to integrate into CI/CD workflows. Add a step to run `./vendor/bin/server-check` or call the API programmatically, then fail the pipeline if requirements aren’t met.
- What if my Laravel app doesn’t use Craft CMS—can I still use this for general PHP server checks?
- While the package is tailored for Craft CMS, you can extend or override its validation rules to focus on Laravel-specific requirements (e.g., `bcmath`, `fileinfo`). However, for pure Laravel projects, Laravel’s built-in tools like `php artisan serve` or `php -m` may suffice.
- How do I customize the validation rules to ignore Craft CMS-specific checks?
- The package allows customization via its API. You can filter or override validation logic to exclude Craft CMS-specific checks (e.g., database tables, Craft plugins). For example, extend the `ServerCheck` class and modify the rules array before calling `validate()`.
- Does this package add significant runtime overhead during deployment?
- The overhead is minimal, as the package performs lightweight system and PHP configuration checks. For CI/CD, the impact is negligible. If performance is critical, consider running checks only in pre-deployment hooks rather than during runtime.
- Are there alternatives to craftcms/server-check for Laravel server validation?
- For Laravel-specific checks, tools like `php -m`, `laravel-debugbar`, or custom scripts may suffice. However, if you need Craft CMS compatibility (e.g., shared hosting, plugins), this package fills a niche by combining Craft CMS and Laravel validation in one tool.
- How do I integrate this into a Laravel service provider or boot event?
- Add the validation to your service provider’s `boot()` method or a Laravel event listener. For example, instantiate `ServerCheck`, call `validate()`, and throw an exception if requirements fail. This ensures checks run before critical operations like database migrations.
- What should I do if the package flags false positives for my Laravel-only environment?
- False positives typically occur due to Craft CMS-specific checks. Mitigate this by extending the package’s validation logic to ignore irrelevant rules. For instance, exclude checks for `craft` database tables or Craft-specific PHP extensions if your Laravel app doesn’t use them.