PHP code example of hyperf-apex / core
1. Go to this page and download the library: Download hyperf-apex/core 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/ */
hyperf-apex / core example snippets
final readonly class StoreUserRequestDTO extends AbstractDTO
{
public function __construct(
#[Length(min: 1, max: 32)]
public string $name = '',
#[FromQuery]
public ?int $from = null,
) {
}
}
#[Controller(prefix: '/users')]
final class UserController extends AbstractController
{
#[Authenticated]
#[RequirePermission('user:create')]
#[PostMapping(path: '')]
public function store(#[FromBody] StoreUserRequestDTO $request): ApiResponseDTO
{
return ApiResponseDTO::success(['id' => 1]);
}
}
bash
php bin/hyperf.php vendor:publish hyperf-apex/core --id=config