承接 b13/slimphp-bridge 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

b13/slimphp-bridge

Composer 安装命令:

composer require b13/slimphp-bridge

包简介

Provides a middleware for registering Slim PHP applications within TYPO3 Frontend Sites

README 文档

README

Boot up a SlimPHP application within a PSR-15 middleware of the TYPO3 Frontend Request.

There are two things you need for this:

  1. Create your endpoints with a SlimPHP RequestResponseArgs strategy in PHP
  2. Configure your endpoints in your site configuration file

Clear caches and you should be good to go.

Description

TYPO3 v9 offers a flexible way to hook into the Frontend Rendering process and do something completely different - thanks to PSR-7 and PSR-15.

SlimPHP is also based on the PSR standards and is a perfect fit if a TYPO3 developer needs to integrate a proper API via e.g. REST.

This small wrapper extension helps to get going very quickly when needing a small API layer for arbitrary endpoints. It is not meant to become a fully headless solution for TYPO3 as a CMS.

However, a TYPO3 PHP developer should be familiar with starting off really quickly to handle custom endpoints without having to write TypoScript.

Installation

Install it via composer req b13/slimphp-bridge (currently composer-only as some PHP dependencies are needed).

Activate the extension in the backend of TYPO3.

Configuration

Then adapt your site configuration to add custom routes.

The type: slim entry enables a SlimPHP Application. The current Site object is then available in the request object.

routes:
  - route: '/api'
    type: 'slim'
    # add middlewares for the whole application. Convenient for any error handling or adding Preflight checks (OPTIONS)
    middlewares:
      - 'B13\MyExtension\Middleware\PreflightCheck'
    groups:
    - route: '/v1'
      middlewares:
        # enable this if you don't manage your languages via the URL endpoint + the base site handling.
        - 'B13\SlimPhp\Middleware\PreferredClientLanguageSelector'
        # enable this if you need extbase in your custom setup
        - 'B13\SlimPhp\Middleware\ExtbaseBridge'
      routes:
        # load a file
        - methods: [any]
          route: '/schema.json'
          file: 'EXT:myextension/Resources/Private/Api/schema_v1.json'
          contentType: 'application/json'
        - methods: [get]
          route: '/article'
          callback: B13\MyExtension\Controller\LoadArticlesController
        - methods: [get]
          route: '/customer'
          callback: B13\MyExtension\Controller\CustomerController:fetchAll
          middlewares: [B13\MyExtension\Middleware\JwtAuthentication]
        - methods: [get]
          route: '/customer/{id}'
          callback: B13\MyExtension\Controller\Api\CustomerController:fetch
          middlewares: [B13\MyExtension\Middleware\JwtAuthentication]
        - methods: [put]
          route: '/customer/{id}'
          callback: B13\MyExtension\Controller\Api\CustomerController:update
          middlewares: [B13\MyExtension\Middleware\JwtAuthentication]

The configuration is similar to what you can do with SlimPHP and with TYPO3, and your controllers just follow the RequestResponseArgs strategy pattern in SlimPHP.

Once you create your endpoints (callbacks), clear your caches and you can run your installation directly.

TYPO3 10.4: If you wan't to use DI in your callbacks, you will have to make them public in the DI configuration:

services:
  B13\MyExtension\Controller\Api\CustomerController:
    public: true

Currently, the extension ships with Tobias Nyholm's PSR implementation, as this provides proper PSR-17 factories.

Caveats

Every time you change your configuration, ensure to clear the TYPO3 core caches.

ToDo

  • More documentation to get started and define all options available
  • More Tests
  • More flexibility with the routing parameters
  • Proper error handling

License

As TYPO3 Core, this extension is licensed under GPL2 or later. See the LICENSE file for more details.

Authors & Maintenance

This extension was initially created for a customer project by Benni Mack for b13, Stuttgart.

Find more TYPO3 extensions we have developed that help us deliver value in client projects. As part of the way we work, we focus on testing and best practices to ensure long-term performance, reliability, and results in all our code.

b13/slimphp-bridge 适用场景与选型建议

b13/slimphp-bridge 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 49.09k 次下载、GitHub Stars 达 20, 最近一次更新时间为 2020 年 09 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「api」 「typo3」 「slimphp」 「psr-15」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 b13/slimphp-bridge 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 b13/slimphp-bridge 我们能提供哪些服务?
定制开发 / 二次开发

基于 b13/slimphp-bridge 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 49.09k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 20
  • 点击次数: 24
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 20
  • Watchers: 3
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2020-09-16