Download the PHP package bylexus/php-prereqcheck without Composer
On this page you can find all versions of the php package bylexus/php-prereqcheck. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bylexus/php-prereqcheck
More information about bylexus/php-prereqcheck
Files in bylexus/php-prereqcheck
Package php-prereqcheck
Short Description Helper class to create Prerequisite Check scripts for your software packages
License copyright
Homepage https://github.com/bylexus/php-prereqcheck
Informations about the package php-prereqcheck
php-prereqcheck
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.
Features
- 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, ...
Installation using composer
Because this is a "zero" version (0.x.y), composer needs some hints to install this package:
composer.json
:
then:
or install it using the --dev
flag:
Installation without composer
Just clone the git repo:
Then just require the prereq-loader.php
file to setup the autoloader.
Sample usage
For a working example, see example-usage.php
.
Built-in Checks
php_version
Checks if the actual PHP version matches a version comparison.
Example:
php_extension
Checks if the given PHP extension is available.
Example:
php_ini
Checks if a given PHP ini setting matches the criteria. Because it is not (always) possible to determine the type of value, a comparison function is needed in the config:
Example:
Possible comparison functions:
- boolean: Checks if the given value is true-ish or false-ish (e.g. 'Off' means false)
- string: exact string match (e.g. default_timezone = 'Europe/Zurich'). If encapsulated in '/' (e.g. /search/), the string is taken as Perl Regular Expression.
- enabled: Checks if the given bit(s) are set in the ini value (e.g. checks if E_WARNING is set in error_reporting)
- bit_disabled: Checks if the given bit(s) are NOT set in the ini value (e.g. checks if E_NOTICE is disabled in error_reporting)
- number: Checks a number value against a comparison, e.g. if memory_limit is >= 512m.
dir_writable
Checks if a given dir exists and is writable.
Example:
db_pdo_connection
Checks if a PDO connection to a database can be established.
Example:
Note:
The options array must contain the following keys:
- dsn: The PDO dsn
- username: The username to connect
- password. The password to use
Write your own checks
Writing your own checks is very simple. Just provide a \Prereq\PrereqCheck
class and register it with the PrereqChecker.
Then you can run the defined check:
Prerequisite (yes, it can check itself :-) )
- PHP >= 5.3.0
Version History
- 0.1.1 First release
- 0.2.0 Introduced Namespace
Prereq
, and make use of the Composer autoload facility. NOTE: This version is NO LONGER compatible with 0.1.1! - 0.2.1 Fixes PHP ini number comparisons: -1 now counts as "unlimited" or max integer
(e.g. to support
memory_limit = -1
)