PHP code example of timefrontiers / php-instance-error
1. Go to this page and download the library: Download timefrontiers/php-instance-error 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/ */
timefrontiers / php-instance-error example snippets
use TimeFrontiers\InstanceError;
$extractor = new InstanceError($service);
// Grouped tuples visible to the current session rank.
$visible = $extractor->get();
// Flat list of tuples from one context.
$validation = $extractor->get('validation');
// Flat list of strings from one context.
$validationMessages = $extractor->get('validation', true);
if ($extractor->has('validation')) {
$first = $extractor->first('validation');
$count = $extractor->count('validation');
}
use TimeFrontiers\AccessRank;
use TimeFrontiers\InstanceError;
$developerView = new InstanceError($service, AccessRank::DEVELOPER);
$rankFiveView = new InstanceError($service, 5);
use TimeFrontiers\InstanceError;
// Logs only errors visible to the normal session-resolved extractor.
$displayExtractor = new InstanceError($service);
$displayExtractor->log('validation');
// Trusted server-side flow: deliberately ;
$extractor->put('custom', [
AccessRank::GUEST->value,
400,
'Something went wrong.',
__FILE__,
__LINE__,
]);
use TimeFrontiers\Helper\HasErrors;
final class Service {
use HasErrors;
public function process():bool {
$this->_userError('process', 'The request could not be processed.', 400);
return false;
}
}
_addError(
string $context,
string $message,
int $minimumRank = AccessRank::GUEST->value,
int $code = 256,
string $file = '',
int $line = 0,
): void
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.