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\Facades\EnterpriseGovernance;

$decision = EnterpriseGovernance::reviewDeployment([
    'environment' => 'production',
    'version' => 'v1.8.0',
    'actor_id' => $user->id,
    'changes' => [
        'app/Services/BillingService.php',
        'database/migrations/2026_05_20_000000_add_invoice_status.php',
    ],
    'approvals' => ['cto'],
    'scheduled_at' => now()->toIso8601String(),
    'metadata' => [
        'migration_reviewed' => true,
        'change_ticket' => 'OPS-1842',
    ],
]);

if ($decision->denied()) {
    return response()->json([
        'message' => 'Deployment blocked by enterprise governance policy.',
        'reasons' => $decision->reasons,
    ], 422);
}

EnterpriseGovernance::audit('ops.runbook.generated', [
    'runbook' => 'production-deploy',
    'change_ticket' => 'OPS-1842',
]);

$decision = EnterpriseGovernance::reviewAi([
    'use_case' => 'support.reply',
    'provider' => 'openai',
    'model' => 'gpt-5.2',
    'prompt' => 'Write a concise customer support reply.',
    'metadata' => [
        'tenant_id' => $tenant->id,
    ],
    'user_id' => $user->id,
]);

EnterpriseGovernance::assertAiAllowed([
    'provider' => 'openai',
    'model' => 'gpt-5.2',
    'prompt' => $prompt,
]);

use Vds\LaravelEnterpriseGovernance\Http\Middleware\EnsureAiRequestAllowed;

Route::post('/ai/reply', ReplyController::class)
    ->middleware(EnsureAiRequestAllowed::class);

$decision = request()->attributes->get('enterprise_governance_decision');

'deployment' => [
    'protected_environments' => ['production'],
    ' => [
        'production' => [
            [
                'days' => ['Mon', 'Tue', 'Wed', 'Thu'],
                'start' => '09:00',
                'end' => '17:00',
                'timezone' => 'UTC',
            ],
        ],
    ],
],

'ai' => [
    'allowed_providers' => ['openai'],
    'allowed_models' => [
        'openai' => ['gpt-5.2'],
    ],
    'limits' => [
        'max_prompt_characters' => 12000,
    ],
],

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');
    }
}
bash
php artisan enterprise-governance:install
php artisan migrate
bash
php artisan enterprise-governance:deployment-check \
  --environment=production \
  --version="$GITHUB_SHA" \
  --actor="$GITHUB_ACTOR" \
  --changed=database/migrations/2026_05_20_000000_add_invoice_status.php \
  --approval=cto \
  --migration-reviewed
bash
php artisan enterprise-governance:doctor