PHP code example of tork / governance

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

    

tork / governance example snippets




use Tork\Governance\Core\Tork;

$tork = new Tork();

$result = $tork->govern("Contact [email protected] or call 555-123-4567");

echo $result->action;  // "redact"
echo $result->output;  // "Contact [EMAIL_REDACTED] or call [PHONE_REDACTED]"

$tork = new Tork();

// UAE regional detection — Emirates ID, +971 phone, PO Box
$result = $tork->govern(
    "Emirates ID: 784-1234-1234567-1",
    region: ['ae']
);

// Multi-region + industry
$result = $tork->govern(
    "Aadhaar: 1234 5678 9012, ICD-10: J45.20",
    region: ['in'],
    industry: 'healthcare'
);

// Available regions: AU, US, GB, EU, AE, SA, NG, IN, JP, CN, KR, BR
// Available industries: healthcare, finance, legal

// In routes/api.php
Route::middleware('tork')->group(function () {
    Route::post('/users', [UserController::class, 'store']);
});

// Publish config (optional)
php artisan vendor:publish --tag=tork-config

$tork = $request->attributes->get('tork');
$receipts = $request->attributes->get('torkReceipts');

// config/bundles.php
return [
    // ...
    Tork\Governance\Symfony\TorkBundle::class => ['all' => true],
];

class ApiController extends AbstractController
{
    public function index(Request $request): JsonResponse
    {
        $tork = $request->attributes->get('tork');
        $receipts = $request->attributes->get('torkReceipts');

        // Your logic here...
    }
}