@lexi.ch home, code, stuff


Check me out on Github!

Helper class to create Prerequisite Checks. It allows you to easily create a Prerequisite Check Script for your project, e.g. matching (php) version, installed extensions, settings etc. It also allows you to write your own checks to implement individual checks.


  • Simple to use API to create own prerequisite scripts / checks
  • Console, Web or silent (programmatic) output
  • Builtin-checks:
    • php version check
    • php ini settings check
    • php extension checks
    • PDO DB connection check
    • dir writable check
  • Extensible: Write your own Check classes easily

Planned features

  • Output renderers to customize output
  • more built-in checks like http service availability, internet access, ...

Sample usage

# Include class and instantiate a PrereqChecker:
$pc = new PrereqChecker();

# Check PHP version:

# Check for installed PHP extensions:

# Check for php.ini settings:
# check a php.ini string using a regular expression:

# Check if dir exists and is writable:

# Check if a PDO DB Connection could be established:

# Create own checks:
class FileExistsChecker extends PrereqCheck {
    public function check($filename = null) {
        $this->name = "File exists: {$filename}";
        if (file_exists($filename)) {
        } else {
            $this->setFailed('File does not exists.');

# Each check returns a CheckResult instance:
$res = $pc->checkMandatory('php_version','>=','5.3.0');
if ($res->success()) {
    echo "Yes, your PHP version is compliant.";

# did all the checks succeed?
if ($pc->didAllSucceed()) {
    echo "All tests succeeded!\n";
} else {
    echo "Some tests failed. Please check.\n";