1. Go to this page and download the library: Download ufo-tech/rest-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/ */
ufo-tech / rest-bundle example snippets
use Ufo\RpcObject\RPC;
use Symfony\Component\Routing\Attribute\Route;
#[RPC\Info(alias: 'User')]
#[Route('/users', name: 'users')]
class UserProcedure implements IRpcService
{
#[Route('/', name: 'create', methods: ['POST'])]
public function create(
#[RPC\Assertions([
new Assert\NotBlank(),
])]
string $role,
#[RPC\Assertions([
new Assert\NotBlank(),
new Assert\Regex(
pattern: '/^\+380\d{9}$/', message: 'The phone number is not a valid UA mobile number'
),
])]
string $phone,
#[RPC\Assertions([
new Assert\NotBlank(),
new Assert\Length(min: 3),
])]
string $firstName,
#[RPC\Assertions([
new Assert\NotBlank(),
new Assert\Length(min: 3),
])]
string $lastName,
): string
{
// create user
}
#[Route('/{userId}', name: 'update', methods: ['PUT'])]
public function update(
#[RPC\Assertions([
new Assert\NotBlank(),
new Assert\Uuid(),
])]
string $userId,
#[RPC\Assertions([
new Assert\NotBlank(),
new Assert\Length(min: 3),
])]
string $firstName,
#[RPC\Assertions([
new Assert\NotBlank(),
new Assert\Length(min: 3),
])]
string $lastName,
): string
{
// update user
}
}
user.getList
json
POST /rest/user/getList
{
"page": 1,
"limit": 20
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.