1. Go to this page and download the library: Download waysnx/business-framework 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/ */
waysnx / business-framework example snippets
// In a service provider's boot() method:
$workflowRegistry = app(WorkflowRegistry::class);
$workflowRegistry->register(OnboardingDefinition::create());
$entityRegistry = app(EntityRegistry::class);
$entityRegistry->register(EmployeeDefinition::create());
// In a service provider's boot() method:
$workflowRegistry = app(WorkflowRegistry::class);
$workflowRegistry->register(OnboardingDefinition::create());
use WaysNX\BusinessFramework\Registry\WorkflowRegistry;
use WaysNX\BusinessFramework\Workflow\WorkflowEngine;
use WaysNX\BusinessFramework\Workflow\WorkflowContext;
class AuditController {
public function __construct(
private WorkflowRegistry $workflows,
private WorkflowEngine $engine
) {}
public function startAudit() {
// Retrieve workflow definition from registry
$workflow = $this->workflows->findById('audit-review');
// Create execution context
$context = new WorkflowContext(
workflowId: 'audit-review',
executionId: 'audit-' . uniqid(),
entity: $audit,
inputData: ['department' => $audit->department]
);
// Execute workflow
$result = $this->engine->execute('audit-review', $context);
if ($result->succeeded()) {
// Handle success
} else {
// Handle failure
foreach ($result->errors as $error) {
logger()->error($error);
}
}
}
}
// All components are bound as singletons:
$this->app->singleton(WorkflowRegistry::class, ...);
$this->app->singleton(WorkflowEngine::class, ...);
$this->app->singleton(ValidationFramework::class, ...);
// ... and others