1. Go to this page and download the library: Download voku/itp-context 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/ */
voku / itp-context example snippets
declare(strict_types=1);
namespace Acme\Context;
use Acme\Tests\I18nTest;
use ItpContext\Contract\RuleIdentifier;
use ItpContext\Enum\Tier;
use ItpContext\Model\RuleDef;
enum ArchitectureRules implements RuleIdentifier
{
case ViewAbstraction;
case I18n;
public function getDefinition(): RuleDef
{
return match ($this) {
self::ViewAbstraction => new RuleDef(
statement: 'Use a dedicated view abstraction for rendering.',
tier: Tier::Standard,
owner: 'Team-Architecture',
rationale: 'A dedicated view layer keeps rendering concerns isolated from domain and controller code.',
refs: ['docs/adr/view-abstraction.md', 'docs/ui/rendering.md'],
),
self::I18n => new RuleDef(
statement: 'Use locale-aware formatting and translated UI labels.',
tier: Tier::Standard,
owner: 'Team-Architecture',
rationale: 'Locale-aware rendering avoids user-facing regressions once the UI contains translated labels and formatted values.',
verifiedBy: [I18nTest::class],
refs: ['docs/adr/i18n.md'],
),
};
}
}
declare(strict_types=1);
namespace Acme\Ui;
use Acme\Context\ArchitectureRules;
use ItpContext\Attribute\Rule;
#[Rule(ArchitectureRules::ViewAbstraction)]
final class DashboardView
{
#[Rule(ArchitectureRules::I18n)]
public function render(): string
{
return 'ok';
}
}
declare(strict_types=1);
use Acme\Context\ArchitectureRules;
use ItpContext\Service\Validator;
$errors = (new Validator())->validateEnumClass(ArchitectureRules::class);
declare(strict_types=1);
use ItpContext\Service\Summarizer;
$output = (new Summarizer())->summarize(__DIR__ . '/src/Ui/DashboardView.php');
declare(strict_types=1);
use ItpContext\Service\ContextExporter;
$report = (new ContextExporter())->export(
outputDir: __DIR__ . '/var/itp-context',
sourceDirs: [__DIR__ . '/src'],
excludePaths: ['vendor', 'tests'],
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.