konradmichalik/typo3-routing 问题修复 & 功能扩展

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

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

konradmichalik/typo3-routing

Composer 安装命令:

composer require konradmichalik/typo3-routing

包简介

Attribute Routing - Register frontend endpoints via PHP attributes on controller methods, as an attribute-based alternative to the missing frontend counterpart of AjaxRoutes.php.

README 文档

README

Extension icon

TYPO3 extension typo3_routing

Latest Stable Version Supported TYPO3 versions Supported PHP Versions CGL Coverage Tests License

This extension lets you register frontend endpoints via PHP attributes on controller methods — the attribute-based counterpart to the backend-only Configuration/Backend/AjaxRoutes.php. It is response-format agnostic: return JSON, HTML, XML, or a download.

Warning

This package is in early development stage and may change significantly in the future. I am working steadily to release a stable version as soon as possible.

Note

The goal is a familiar, Symfony-Routing-like developer experience: declare a frontend endpoint with a single #[Route] attribute instead of wiring a custom middleware and duplicating the path across PHP and JavaScript.

✨ Features

  • Attribute routing — declare an endpoint with #[Route] directly on a controller method
  • Typed arguments — methods receive type-cast path/query/body values, no manual request reading
  • Zero-config discovery — routes are collected at container compile time, no extra cache
  • URL generation — a Fluid ViewHelper so the path lives once, not duplicated as a PHP constant and a JS string
  • Opt-in caching — cache responses with #[Cache], with tag-based invalidation
  • Opt-in rate limiting — throttle requests per client IP with #[RateLimit]
  • Opt-in authentication & CSRF — protect routes with #[Authenticate] (bearer token / FE / BE user) and #[RequireRequestToken]
  • Debug command — list every registered route as a table or JSON, including an --unprotected audit

🔥 Installation

Requirements

  • TYPO3 >= 13.4
  • PHP 8.2+

Composer

Packagist Packagist Downloads

composer require konradmichalik/typo3-routing

TER

TER version TER downloads

Download the zip file from TYPO3 extension repository (TER).

🚀 Quick start

Implement RouteControllerInterface, register the controller as a service, and annotate a public method with #[Route]:

use KonradMichalik\Typo3Routing\Attribute\Route;
use KonradMichalik\Typo3Routing\Routing\RouteControllerInterface;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Core\Http\JsonResponse;

final readonly class CourseSearchController implements RouteControllerInterface
{
    #[Route(path: '/api/course-search/count', name: 'course_search_count')]
    public function count(): ResponseInterface
    {
        return new JsonResponse(['count' => 42]);
    }
}

That's it — GET /api/course-search/count now returns your JSON.

Everything else is opt-in on top of that. A route can take typed arguments, validate input, cache its response, and throttle clients — all declared with attributes, the controller stays plain:

use Symfony\Component\Routing\Requirement\Requirement;

#[Route(path: '/api/courses/{id}', name: 'course_show', requirements: ['id' => Requirement::DIGITS])]
#[Cache(lifetime: 3600, tags: ['tx_courses_domain_model_course'])]
#[RateLimit(limit: 60, interval: '1 minute')]
public function show(int $id, int $page = 1): ResponseInterface
{
    // $id  ← path placeholder, cast to int (404 if not digits)
    // $page ← ?page=… query param, defaults to 1
    return new JsonResponse(/* … */);
}

Protecting a route is just as declarative — require a logged-in frontend user (or a bearer token / BE user, OR-combined):

#[Route(path: '/api/account', name: 'account')]
#[Authenticate(FrontendUserAuthenticator::class)]
public function account(): ResponseInterface
{
    // Reached only when a frontend user is logged in — 401 otherwise.
    return new JsonResponse(/* … */);
}

See Usage for the full #[Route] reference and typed arguments.

📚 Documentation

Topic What's inside
Usage The #[Route] attribute, requirements, and typed controller arguments
URL Generation routing:uri / routing:uris Fluid ViewHelpers and the PHP generator
Configuration Path prefix gate, environment-bound routes, middleware placement
Caching Opt-in response caching with #[Cache] and tag-based invalidation
Rate Limiting Opt-in per-IP throttling with #[RateLimit]
Authentication & CSRF Protecting routes with #[Authenticate], request tokens, and deployment notes
How It Works Compile-time discovery, runtime dispatch, and the routing:debug command
How It Compares When to reach for this vs. AjaxRoutes, custom middleware, eID, or Extbase plugins

🧑‍💻 Contributing

Please have a look at CONTRIBUTING.md.

⭐ License

This project is licensed under GNU General Public License 2.0 (or later).

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2026-06-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固