1. Go to this page and download the library: Download izzle/healthcheck 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/ */
izzle / healthcheck example snippets
namespace App\HealthChecks;
use Izzle\HealthCheck\CheckInterface;
use Izzle\HealthCheck\Response;
use Exception;
/**
* Class FolderPermissionCheck
* @package App\HealthChecks
*/
class FolderPermissionCheck implements CheckInterface
{
/**
* @return string
*/
public function getName(): string
{
return 'folder-permission';
}
/**
* @param array|null $params
* @return Response
*/
public function run(?array $params = []): Response
{
try {
if (!is_writable('/some/folder')) {
throw new Exception('Folder /some/folder is not writeable!');
}
} catch (Exception $e) {
return new Response(false, $e->getMessage());
}
return new Response(true);
}
}
namespace App;
use Izzle\HealthCheck\Manager;
use Izzle\HealthCheck\Checks\NullCheck;
use App\HealthChecks\FolderPermissionCheck;
$manager = new Manager([
new NullCheck(),
new FolderPermissionCheck()
]);
$results = $manager->run();
$result = [
'global' => true,
'components' => []
];
foreach ($results as $component => $response) {
if ($response->getStatus() === false) {
$result['global'] = false;
}
$result['components'][$component] = $response->getStatus();
}
echo json_encode($result);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.