PHP code example of crustum / structarmed-cakephp

1. Go to this page and download the library: Download crustum/structarmed-cakephp 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/ */

    

crustum / structarmed-cakephp example snippets


return Architecture::define()
    ->withPreset(new CakeAppPreset(
        pluginNamespaces: ['Billing', 'Inventory'],
        // pluginAppAccess: ['Billing' => ['App\Util']],  // grant app kernel access
    ));

// structarmed.php
use Boundwize\StructArmed\Architecture;
use Crustum\StructArmed\Cake\CakeAppPreset;

return Architecture::define()
    ->layer('Source', [])                 // PSR-4 scan paths (needed for the PHPUnit extension)
    ->withPreset(new CakeAppPreset())
    ->ruleset([                           // your own domain layers, if any
        // ...
    ]);

new CakeAppPreset(
    namespace: 'App',           // root namespace (no trailing backslash)
    controllerMaxComplexity: 3, // default: 5
    controllerMaxMethodLength: 15, // default: 20
    controllerMaxDependencies: 4, // default: 5
    viewMaxComplexity: 2,       // default: 3 — View classes should just load helpers
)

use Crustum\StructArmed\Cake\CakeAppPreset;

return Architecture::define()
    ->withPreset(new CakeAppPreset())
    ->skip(CakeAppPreset::CONTROLLER_MAX_DEPENDENCIES);          // whole rule
    // or: ->skip([CakeAppPreset::ENTITY_MUST... => ['src/Legacy/']]);

use Crustum\StructArmed\Cake\CakeRule;

return Architecture::define()
    ->withPreset(new CakeAppPreset())
    ->skip(CakeRule::CONTROLLER_MAX_DEPENDENCIES->value);