PHP code example of abdulsalamalkhatib / laravel-guardian
1. Go to this page and download the library: Download abdulsalamalkhatib/laravel-guardian 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/ */
abdulsalamalkhatib / laravel-guardian example snippets
// guardian-ignore GUA-003: account owner explicitly requested this field
return response()->json([
'phone' => $player->phone,
]);
use Guardian\Attributes\GuardianIgnore;
#[GuardianIgnore(
rule: 'GUA-003',
reason: 'Internal authenticated endpoint restricted to fraud operations',
)]
final class FraudResource extends JsonResource
{
// ...
}
use Guardian\Attributes\GuardianAllowsSensitive;
#[GuardianAllowsSensitive(
fields: ['phone'],
reason: 'The authenticated account owner explicitly requested their own profile phone number.',
)]
public function toArray($request): array
{
return ['phone' => $this->phone];
}
use Guardian\Application\GuardianRegistry;
use Guardian\Contracts\Plugin;
final class PaymentsGuardianPlugin implements Plugin
{
public function register(GuardianRegistry $registry): void
{
$registry
->rule(new ProviderIdempotencyRule())
->effectProvider(new AcmePaymentEffectProvider())
->sanitizer(new InternalTokenRedactor())
->concurrencyGuard(new WalletMutexGuard());
}
}