📄 中文摘要
Temma 是一个设计简洁易用的 PHP MVC 框架,介于微框架和全栈框架之间,旨在尽量减少开发者的干扰。其核心概念是数据源,提供统一的方式声明和访问任何外部连接,包括数据库、缓存、消息队列或 API。在 Temma 2.16.0 版本中,OpenAI 被纳入了这一列表。大多数 PHP 教程在集成 OpenAI 时需要安装 SDK、编写服务类、手动注入并连接各个部分,虽然可行,但对于远程调用来说显得繁琐。在 Temma 中,OpenAI 被视为一种数据源,开发者可以像声明 MySQL 连接一样简单地使用它。
📄 English Summary
Calling OpenAI from a PHP framework the same way you query a database
Temma is a PHP MVC framework designed for ease of use, positioned between micro-frameworks and full-stack frameworks to minimize developer interference. One of its core concepts is the datasource, which provides a unified way to declare and access any external connection, including databases, caches, message queues, or APIs. In version 2.16.0, OpenAI has been added to this list. Most PHP tutorials for integrating OpenAI involve installing an SDK, writing a service class, manually injecting it, and wiring everything together, which, while functional, is cumbersome for what is essentially a remote call. In Temma, OpenAI is treated as a datasource, allowing developers to use it as simply as declaring a MySQL connection.