struturizr-php / structurizr-php
Structurizr for PHP
Fund package maintenance!
norberttech
Installs: 970
Dependents: 0
Suggesters: 0
Security: 0
Stars: 162
Watchers: 5
Forks: 16
Open Issues: 9
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
- 1.x-dev
- 0.4.0
- 0.3.0
- 0.2.0
- 0.1.0
- dev-dependabot/composer/symfony/http-client-5.4.46
- dev-dependabot/composer/qossmic/deptrac-2.0.2
- dev-dependabot/composer/psr/log-3.0.2
- dev-dependabot/composer/php-cs-fixer/shim-3.64.0
- dev-dependabot/composer/phpunit/phpunit-10.5.27
- dev-dependabot/composer/monolog/monolog-2.9.3
This package is auto-updated.
Last update: 2024-11-06 15:59:38 UTC
README
This repository is a port of Structurizr for Java. All credits for creating C4 goes of course to Simon Brown this library is nothing more that simple port of the code that already exists in other language.
How to Use
Installation
composer require structurizr-php/structurizr-php
A quick example
As an example, the following PHP code can be used to create a software architecture model and an associated view that describes a user using a software system.
<?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);
The view can then be exported to be visualised in a number of different ways; e.g. PlantUML, Structurizr and Graphviz:
More Examples
Hire in Social
Hire in Social - project example