1. Go to this page and download the library: Download dakujem/strata74 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/ */
dakujem / strata74 example snippets
use Dakujem\Strata\Http\UnprocessableContent;
if(!isEmail($input['email'])){
// HTTP 422
throw (new UnprocessableContent('Invalid e-mail address.'))
// Convey messages to clients with localization support and metadata:
->convey(
message: __('Please enter a valid e-mail address.'),
source: 'input.email',
)
// Add details for developers to be reported or logged:
->pin([
'name' => $input['name'],
'email' => $input['email'],
], key: 'input');
}
use Dakujem\Strata\LogicException;
throw (new LogicException('Invalid value of Something.'))
// Convey messages and meta-data to clients, humans and apps alike:
->convey(
message: __('We are sorry, we encountered an issue with Something and are unable to fulfil your request.'),
source: 'something.or.other',
description: __('We are already fixing the issue, please try again later.'),
meta: ['param' => 42]
)
// Add details for developers to be reported or logged:
->explain('Fellow developers, this issue is caused by an invalid value: ' . $someValue)
->pin(['value' => $someValue, 'severity' => 'serious'], 'additional context')
->pin(['other' => $value], 'other context')
->pin('anything')
->tag('something')
->tag(tag: 'serious', key: 'severity')
;
class MySpecificException extends WhateverBaseException implements SupportsContextStrata
{
use ContextStrata;
public function __construct($message = null, $code = 0, Throwable $previous = null)
{
parent::__construct(
$message ?? 'This is the default message for my specific exception.',
$code ?? 0,
$previous,
);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.