PHP code example of kodzila / architecture-validator

1. Go to this page and download the library: Download kodzila/architecture-validator 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/ */

    

kodzila / architecture-validator example snippets


use Kodzila\ArchValidator\Architecture;
use Kodzila\ArchValidator\Rule\CoreModuleRule;
use PHPUnit\Framework\TestCase;

final class ArchitectureTest extends TestCase
{
    public function test(): void
    {
        $architecture = Architecture::build()
            ->defineModule(
                'Core',
                'Isav\\Core\\',
                'src/Core'
            )
            ->defineModule(
                'Armap',
                'Isav\\Armap\\',
                'src/Armap'
            )
            ->defineModule(
                'Import',
                'Isav\\Import\\',
                'src/Import'
            )
        ;

        $architecture->checkRule(new CoreModuleRule('Core'));
        $this->assertTrue(true);
    }

}

        $architecture = Architecture::build()
            ->defineModule(
                'Core',
                'Isav\\Core\\',
                'src/Core'
            )
            ->defineModule(
                'Armap',
                'Isav\\Armap\\',
                'src/Armap'
            )
        ;

$architecture->checkRules([
    new DomainForbiddenDependenciesRule(['Core'], [
          'Doctrine\ORM\Mapping',
          'Doctrine\Common\Collections',
          'Ramsey\Uuid\UuidInterface',
    ])
]);
xml
<testsuites>
        <testsuite name="Architecture">
            <directory>tests/Architecture</directory>
        </testsuite>
    </testsuites>
text
.
+-- config
|   +-- services.yaml
|   +-- routing.yaml
+-- src
|   +-- Armap
|      +-- SyncService.php
|   +-- Core
|      +-- CoreEntity.php
|   +-- DoctrineMigrations
|      +-- Migration214312412.php
+-- tests
|   +-- E2E.php