craftcms/server-check
Command-line and web-based server requirements checker for Craft CMS 4. Run via curl|bash on Unix-like systems or upload the server/ folder to get HTML or plain-text reports. Supports strict mode and CI/Docker-friendly exit codes.
Quick CLI Check: Run in a Unix-like terminal (Linux, macOS, WSL):
curl -Lsf https://raw.githubusercontent.com/craftcms/server-check/HEAD/check.sh | bash
0 (pass), 1 (fail/warning).CRAFT_STRICT_SERVER_CHECK=1 to fail on warnings:
CRAFT_STRICT_SERVER_CHECK=1 php server/checkit.php
Web UI Report:
server/ folder to your web root.checkit.php via browser for an HTML report.Remote CLI:
server/ to any server path.php /path/to/server/checkit.php
Pre-deployment validation for a Laravel + Craft CMS hybrid project:
# Add to your CI/CD pipeline (e.g., GitHub Actions)
- name: Validate Server Requirements
run: curl -Lsf https://raw.githubusercontent.com/craftcms/server-check/HEAD/check.sh | bash
# Fail if warnings exist (strict mode)
env:
CRAFT_STRICT_SERVER_CHECK: "1"
CI/CD Integration:
jobs:
server-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Server Check
run: |
curl -Lsf https://raw.githubusercontent.com/craftcms/server-check/HEAD/check.sh | bash
if [ $? -ne 0 ]; exit 1; fi
CRAFT_STRICT_SERVER_CHECK=1 to fail on warnings.Docker Build Validation:
Dockerfile:
RUN curl -Lsf https://raw.githubusercontent.com/craftcms/server-check/HEAD/check.sh | bash
Local Development:
~/.bashrc:
alias craft-check='curl -Lsf https://raw.githubusercontent.com/craftcms/server-check/HEAD/check.sh | bash'
composer install or php artisan serve.Webhook-Based Validation:
server/ to a subdomain (e.g., check.yourdomain.com).checkit.php via API or cron for remote servers.Custom Artisan Command:
// app/Console/Commands/CheckServer.php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class CheckServer extends Command {
protected $signature = 'craft:server-check';
public function handle() {
$output = shell_exec('php artisan vendor:publish --provider="craftcms/server-check"');
$this->info($output);
}
}
app/Console/Kernel.php:
protected $commands = [
Commands\CheckServer::class,
];
Service Provider Hook:
boot():
// app/Providers/AppServiceProvider.php
public function boot() {
if (app()->environment('production')) {
$this->validateServer();
}
}
protected function validateServer() {
$exitCode = shell_exec('php server/checkit.php');
if ($exitCode !== 0) {
throw new \RuntimeException('Server requirements not met!');
}
}
Laravel Mix/Webpack:
// webpack.mix.js
mix.webpackConfig({
devServer: {
before: (app) => {
return require('child_process').execSync('php server/checkit.php');
}
}
});
Event Listener:
Illuminate\Foundation\Bootstrap\LoadConfiguration:
// app/Providers/EventServiceProvider.php
protected $listen = [
'Illuminate\Foundation\Bootstrap\LoadConfiguration' => [
App\Listeners\ValidateServer::class,
],
];
Custom Requirements:
RequirementsChecker (in server/RequirementsChecker.php):
// Add to server/RequirementsChecker.php
public function checkCustomRequirement() {
return new RequirementResult(
'Custom Requirement',
'Your custom check description',
function() {
return extension_loaded('your_extension');
}
);
}
Database-Specific Checks:
checkDatabase() to add Laravel-specific DB validations:
public function checkDatabase($dsn) {
$results = parent::checkDatabase($dsn);
// Add Laravel-specific checks (e.g., MySQL strict mode)
$results[] = new RequirementResult(
'MySQL Strict Mode',
'MySQL must be in strict mode for Laravel compatibility.',
function() use ($dsn) {
// Implement check logic
}
);
return $results;
}
Output Formatting:
server/RequirementsChecker.php to integrate with Laravel’s logging:
public function getReport() {
$report = parent::getReport();
\Log::info('Server Check Report', ['report' => $report]);
return $report;
}
Exit Code Misinterpretation:
1 can mean either a failure or a warning (if CRAFT_STRICT_SERVER_CHECK=1 is set).CRAFT_STRICT_SERVER_CHECK=1 php server/checkit.php
Database Connection Issues:
dsn (Data Source Name) is malformed or the database is unreachable.// Mock DSN for local testing
putenv('CRAFT_SERVER_CHECK_DSN=mysql:host=localhost;dbname=test');
PHP Configuration Overrides:
memory_limit during checks, which might affect other processes.php -d memory_limit=-1 server/checkit.php
False Positives for opcache.save_comments:
opcache.save_comments as disabled even if it’s enabled.php -i | grep opcache.save_comments
Web Root Assumptions:
server/ folder is in the web root. If not, database checks may fail.CRAFT_SERVER_CHECK_WEB_ROOT environment variable:
CRAFT_SERVER_CHECK_WEB_ROOT=/custom/path php server/checkit.php
Verbose Output:
CRAFT_SERVER_CHECK_DEBUG=1 php server/checkit.php
Dry Run:
php -d memory_limit=-1 -d opcache.enable=0 server/checkit.php
Log File:
php server/checkit.php > server-check.log 2>&1
Manual Extension Check:
php -m | grep -E 'gd|intl|opcache|bcmath|json|fileinfo'
| Variable | Purpose | Example |
|---|---|---|
CRAFT_SERVER_CHECK_DSN |
Database DSN for |
How can I help you explore Laravel packages today?