PHP code example of sarfraznawaz2005 / servermonitor

1. Go to this page and download the library: Download sarfraznawaz2005/servermonitor 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/ */

    

sarfraznawaz2005 / servermonitor example snippets


// app/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
   $schedule->command('servermonitor:check')->hourly();
}

use Sarfraznawaz2005\ServerMonitor\ServerMonitor;

$sm = new ServerMonitor();
$checkResults = $sm->getChecks();
dump($checkResults);

\Sarfraznawaz2005\ServerMonitor\Checks\Server\RequiredPhpExtensionsAreInstalled::class => [
    'web_only' => true
],

\Sarfraznawaz2005\ServerMonitor\Checks\Application\AppKeySet::class => [
    'name' => 'Check if APP_KEY is set',
],

\Sarfraznawaz2005\ServerMonitor\Checks\Application\ComposerDependenciesUpToDate::class => [
    'binary_path' => 'composer'
],

\Sarfraznawaz2005\ServerMonitor\Checks\Application\AppKeySet::class => [
    'notification_channel' => 'log',
    'notification_title' => 'Hello World'
]

\Sarfraznawaz2005\ServerMonitor\Checks\Application\AppKeySet::class => [
    'disable_notification' => true
]

use Sarfraznawaz2005\ServerMonitor\Checks\Check;

class MyCheck implements Check
{
    /**
     * Perform the actual verification of this check.
     *
     * @param array $config
     * @return bool
     */
    public function check(array $config): bool
    {
        return 1 === 1;
    }

    /**
     * The error message to display in case the check does not pass.
     *
     * @return string
     */
    public function message(): string
    {
        return "This error message that users see if check returns false.";
    }
}
bash
$ php artisan vendor:publish --provider="Sarfraznawaz2005\ServerMonitor\ServiceProvider"