PHP code example of psecio / canary

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

    

psecio / canary example snippets



$_POST = [
    'username' => '[email protected]',
    'password' => 'sup3rs3cr3t'
];

\Psecio\Canary\Instance::build()->if('username', '[email protected]')->execute();

// Or you can set multiple match values to look for with an array
$matches = [
    'username' => '[email protected]',
    'password' => 'sup3rs3cr3t'
];
\Psecio\Canary\Instance::build()->if($matches)->execute();


$_POST = ['username' => '[email protected]'];

\Psecio\Canary\Instance::build()->if('username', '[email protected]')
    ->then(function($criteria) {
        die("You shouldn't have done that!");
    })
    ->execute();


$config = ['data' => [
    'username' => '[email protected]'
]];
\Psecio\Canary\Instance::build($config)->if('username', '[email protected]')->execute();



// create a log channel
$log = new Logger('name');
$log->pushHandler(new StreamHandler('/tmp/mylog.log', Logger::WARNING));

$config = [
    'notify' => $log
];
\Psecio\Canary\Instance::build($config)->if('username', '[email protected]')->execute();



use Monolog\Logger;
use Monolog\Handler\StreamHandler;

g = new Logger('name');
$log->pushHandler(new StreamHandler('/tmp/mylog.log', Logger::WARNING));

\Psecio\Canary\Instance::build()
    ->if('username', '[email protected]')
    ->then($log)
    ->execute();


$settings = [
	'channel' => '#my-channel-name',
	'link_names' => true
];
$slack = new Maknz\Slack\Client('https://hooks.slack.com/services/.....', $settings);

\Psecio\Canary\Instance::build($config)->if('username', '[email protected]')->then($slack);


$pager = new \PagerDuty\Event();
$pager->setServiceKey('[.... your service ID ....]');

\Psecio\Canary\Instance::build($config)->if('username', '[email protected]')->then($pager);


$classMethod = '\Foo\Bar::criteria';

\Psecio\Canary\Instance::build()->if($classMethod)->execute();