psvneo/typo3-extension-easy-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

psvneo/typo3-extension-easy-api

最新稳定版本:1.0.0

Composer 安装命令:

composer require psvneo/typo3-extension-easy-api

包简介

This extension adds an easy way to provide custom API endpoints for your extensions.

README 文档

README

This extension adds an easy way to provide custom API endpoints for your extensions.

Requirements

  • PHP ^8.2.
  • TYPO3 13.4

Documentation

This extension is a fork of the extension app_routes. It provides a simple way to create custom API endpoints in TYPO3.

Under the hood, it uses Symfonys Routing Component. to resolve the routes.

How to set up a new API endpoint

To create a new API endpoint, you need to create a class that implements the\Psr\Http\Server\RequestHandlerInterface and use the \PSVNEO\PsvneoEasyApi\Attribute\AsEndpoint attribute to define the endpoint's properties.

PropertyDescriptionDefault ValueExample Value
nameA unique name for the endpoint, used to identify it in the system.Requireddummy
pathThe path for the endpoint.Required/api/my-endpoint
methodsThe HTTP methods the endpoint should respond to.All methods['GET']
defaults.cacheIndicates if the endpoint should be cached. Only available for GET and HEAD requests.falsetrue
defaults.tsfeSpecifies if the endpoint requires a loaded TypoScript Frontend (TSFE).falsetrue
defaults.siteIdentifierIf set the api endpoint is only available for the defined site identifier.Defined by the base urlmy-site
namespace Vendor\MyExtensionName\Api;

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use PSVNEO\PsvneoEasyApi\Attribute\AsEndpoint;
use TYPO3\CMS\Core\Http\JsonResponse;

#[AsEndpoint(
    name: 'dummy',
    path: '/api/my-endpoint',
    methods: ['GET'],
    defaults: [
        'cache' => true,
        'tsfe' => true,
        'siteIdentifier' => 'my-site',
    ]
)]
final class MyEndpoint implements RequestHandlerInterface
{
    public function handle(ServerRequestInterface $request): ResponseInterface
    {
         // Your custom logic here...
        return new JsonResponse([
            'success' => true
        ]);
    }
}

统计信息

  • 总下载量: 52
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2025-04-14