PHP code example of tourze / json-rpc-security-bundle

1. Go to this page and download the library: Download tourze/json-rpc-security-bundle 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/ */

    

tourze / json-rpc-security-bundle example snippets


// config/bundles.php
return [
    // ...
    Tourze\JsonRPCSecurityBundle\JsonRPCSecurityBundle::class => ['all' => true],
];

use Symfony\Component\Security\Http\Attribute\IsGranted;
use Tourze\JsonRPC\Core\Domain\JsonRpcMethodInterface;

#[IsGranted(attribute: 'ROLE_ADMIN')]
class AdminMethod implements JsonRpcMethodInterface
{
    // ...
}

use Tourze\JsonRPCSecurityBundle\Attribute\MethodPermission;
use Tourze\JsonRPC\Core\Domain\JsonRpcMethodInterface;

#[MethodPermission("user.edit", "编辑用户信息")]
class UserEditMethod implements JsonRpcMethodInterface
{
    // ...
}