1. Go to this page and download the library: Download mlocati/ci-info library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mlocati / ci-info example snippets
$driver = (new \CIInfo\DriverList())->getDriverForEnvironment();
if ($driver === null) {
// CI environment Not detected
} else {
if ($ci->getHandle() === \CIInfo\Driver\GithubActions::HANDLE) {
// We are running in a GitHub Actions build
}
}
try {
$state = (new \CIInfo\StateFactory())->getCurrentState();
} catch (\CIInfo\Exception $whoops) {
echo "Something went wrong: " . (string) $whoops;
return;
}
switch ($state->getEvent()) {
case \CIInfo\State::EVENT_PUSH:
// $state is an instance of the \CIInfo\State\Push (or its \CIInfo\State\PushWithoutBaseCommit subclass) class
echo "We are in a build triggered by a push.\n";
break;
case \CIInfo\State::EVENT_PULLREQUEST:
// $state is an instance of the \CIInfo\State\PullRequest class
echo "We are in a build triggered by a pull request.\n";
break;
case \CIInfo\State::EVENT_TAG:
// $state is an instance of the \CIInfo\State\Tag class
echo "We are in a build triggered by the creation of a tag.\n";
break;
case \CIInfo\State::EVENT_SCHEDULED:
// $state is an instance of the \CIInfo\State\Scheduled class
echo "We are in a build triggered by a scheduled job.\n";
break;
case \CIInfo\State::EVENT_MANUAL:
// $state is an instance of the \CIInfo\State\Manual class
echo "We are in a build triggered manually (via APIs, manual builds, repository_dispatch events, ...).\n";
break;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.