PHP code example of ausus / authoring

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

    

ausus / authoring example snippets



use Ausus\Authoring\Dsl\Definition;
use Ausus\Authoring\Dsl\Expr;
use Ausus\Definition\Enum\FieldType;
use Ausus\Definition\Enum\ActionKind;

return Definition::make('customer', true)
    ->field('name', FieldType::String)
    ->field('status', FieldType::Enum, [
        'default' => 'inactive',
        'typeOptions' => ['values' => ['active', 'inactive']],
    ])
    ->action('create', ActionKind::Create, [
        'inputs' => ['name'],
        'guard'  => Expr::eq(Expr::actor('type'), 'user'),
    ])
    ->action('activate', ActionKind::Transition, [
        'transition' => ['field' => 'status', 'from' => 'inactive', 'to' => 'active'],
    ])
    ->projection('board', ['fields' => [['field' => 'name'], ['field' => 'status']]])
    ->build();