PHP code example of vds / laravel-enterprise-governance
1. Go to this page and download the library: Download vds/laravel-enterprise-governance 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/ */
vds / laravel-enterprise-governance example snippets
use Vds\LaravelEnterpriseGovernance\Http\Middleware\EnsureAiRequestAllowed;
Route::post('/ai/reply', ReplyController::class)
->middleware(EnsureAiRequestAllowed::class);
use Vds\LaravelEnterpriseGovernance\AIRequest;
use Vds\LaravelEnterpriseGovernance\Contracts\AIReviewPolicy;
use Vds\LaravelEnterpriseGovernance\PolicyResult;
final class TenantAIPolicy implements AIReviewPolicy
{
public function evaluate(AIRequest $request): PolicyResult
{
return $request->metadata['tenant_ai_enabled'] ?? false
? PolicyResult::allow('tenant.enabled')
: PolicyResult::deny('tenant.disabled', 'AI is disabled for this tenant.');
}
}
use Vds\LaravelEnterpriseGovernance\Contracts\DeploymentPolicy;
use Vds\LaravelEnterpriseGovernance\Deployment\DeploymentManifest;
use Vds\LaravelEnterpriseGovernance\PolicyResult;
final class IncidentFreezePolicy implements DeploymentPolicy
{
public function evaluate(DeploymentManifest $manifest): PolicyResult
{
return app(IncidentState::class)->active()
? PolicyResult::deny('deployment.incident_freeze', 'Production is under incident freeze.')
: PolicyResult::allow('deployment.incident_freeze.clear');
}
}