struturizr-php / structurizr-php
0.4.0
2024-04-30 07:54 UTC
Requires
- php: ^7.3 || ^8.0
- ext-iconv: *
- ext-json: *
- beberlei/assert: ^3.2
- psr/http-client: ^1.0
- psr/log: ^1.1
Requires (Dev)
- ergebnis/phpstan-rules: ^0.15.0
- friendsofphp/php-cs-fixer: ^2.16
- monolog/monolog: ^2.0
- nyholm/psr7: ^1.2
- phpstan/phpstan: ^0.12.34
- phpstan/phpstan-phpunit: ^0.12
- phpunit/phpunit: ^8.4 || ^9.0
- sensiolabs-de/deptrac-shim: ^0.6.0 || ^0.12.0 || ^0.13.0 || ^0.14.0
- structurizr-php/extensions-php: @dev
- symfony/http-client: ^4.3 || ^5.0
- symfony/var-dumper: ^4.3 || ^5.0
- thecodingmachine/phpstan-strict-rules: ^0.12
Suggests
- nyholm/psr7: Makes possible to use StructurizrPHP\StructurizrPHP\Infrastructure\Http\SymfonyRequestFactory instead of writing custom implementation
- symfony/http-client: Psr18Client http factory works out of the box with StructurizrPHP\StructurizrPHP\SDK\Client
This package is auto-updated.
Last update: 2024-09-12 02:38:45 UTC
README
此仓库是Java版的Structurizr的移植。所有关于创建C4的荣誉当然归Simon Brown所有,这个库只是简单地将其他语言中已经存在的代码进行了移植。
如何使用
安装
composer require structurizr-php/structurizr-php
快速示例
以下PHP代码示例可用于创建一个软件架构模型和相关联的视图,描述用户使用软件系统。
<?php $workspace = new Workspace( $id = (string)\getenv('STRUCTURIZR_WORKSPACE_ID'), $name = 'Getting Started', $description = 'This is a model of my software system. by structurizr-php/structurizr-php' ); $workspace->getModel()->setEnterprise(new Enterprise('Structurizr PHP')); $person = $workspace->getModel()->addPerson( $name = 'User', $description = 'A user of my software system.', Location::internal() ); $softwareSystem = $workspace->getModel()->addSoftwareSystem( $name = 'Software System', $description = 'My software system.', Location::internal() ); $person->usesSoftwareSystem($softwareSystem, 'Uses', 'Http'); $contextView = $workspace->getViews()->createSystemContextView($softwareSystem, 'System Context', 'system01', 'An example of a System Context diagram.'); $contextView->addAllElements(); $contextView->setAutomaticLayout(true); $styles = $workspace->getViews()->getConfiguration()->getStyles(); $styles->addElementStyle(Tags::SOFTWARE_SYSTEM)->background("#1168bd")->color('#ffffff'); $styles->addElementStyle(Tags::PERSON)->background("#08427b")->color('#ffffff')->shape(Shape::person()); $client = new Client( new Credentials((string) \getenv('STRUCTURIZR_API_KEY'), (string) \getenv('STRUCTURIZR_API_SECRET')), new UrlMap('https://api.structurizr.com'), new Psr18Client(), new SymfonyRequestFactory(), new Logger('structurizr', [new StreamHandler('php://stdout')]) ); $client->put($workspace);
然后可以将视图导出,以多种方式可视化;例如,PlantUML、Structurizr和Graphviz。