Skip to content

Instantly share code, notes, and snippets.

@alister
Last active December 10, 2018 12:47
Show Gist options
  • Save alister/8e3aa440c08b16c6ed48a0e52ff977d5 to your computer and use it in GitHub Desktop.
Save alister/8e3aa440c08b16c6ed48a0e52ff977d5 to your computer and use it in GitHub Desktop.
Sample use of Tombstones
<?php
// ... other code - but NOT requireing 'vendor/autoload.php'
define('SRC_ROOT', __DIR__.'/../src');
define('TOMBSTONE_LOG', dirname(__DIR__)."/var/logs/tombstones.log");
use \Scheb\Tombstone\Tracing\TraceProvider;
use \Scheb\Tombstone\GraveyardProvider;
use \Scheb\Tombstone\Handler\StreamHandler;
if (!function_exists('tombstone')) {
/**
* @param string $date Any date format strtotime() understands
* @param string $author Your name
* @param string|null $label An optional label for the tombstone
*/
function tombstone($date, $author, $label = null) {
try {
$trace = TraceProvider::getTraceHere();
GraveyardProvider::getGraveyard()->setSourceDir(SRC_ROOT);
$streamHandler = new StreamHandler(TOMBSTONE_LOG);
GraveyardProvider::getGraveyard()->addHandler($streamHandler);
GraveyardProvider::getGraveyard()->tombstone($date, $author, $label, $trace);
// in dev, we `dump() and die` here.
} catch (\Exception $e) {
// in production - we swallow any errors from the Tombstone system
}
}
}
require '/../vendor/autoload.php';
<?php
namespace DemoCode;
class MightBeDead
{
public function tombstoneExample()
{
tombstone('2017-08-26', 'ab');
// this function might be redundant
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment