chiron / chiron
Chiron 是一个 PHP 微型框架
3.9.22
2022-04-13 15:16 UTC
Requires
- php: ^8.0|^8.1
- ext-intl: *
- ext-json: *
- ext-mbstring: *
- ext-xml: *
- chiron/core: ^1.0
- chiron/discover: ^1.0
- chiron/security: ^1.0
Requires (Dev)
- chiron/coding-standard: ^3.0
- filp/whoops: ^2.2
- nyholm/psr7: ^1.4
- phpstan/phpstan: ^0.12.0
- phpstan/phpstan-phpunit: ^0.12
- phpunit/phpunit: ^9.5
Suggests
- filp/whoops: Enables use of the debug displayer.
- dev-master
- 3.9.22
- 3.9.21
- 3.9.20
- 3.9.19
- 3.9.18
- 3.9.17
- 3.9.16
- 3.9.15
- 3.9.14
- 3.9.13
- 3.9.12
- 3.9.11
- 3.9.10
- 3.9.9.4
- 3.9.9.3
- 3.9.9.2
- 3.9.9.1
- 3.9.9
- 3.9.8
- 3.9.7
- 3.9.6
- 3.9.5
- 3.9.4
- 3.9.3
- 3.9.2
- 3.9.1
- 3.9
- 3.8.1
- 3.8
- 3.7
- 3.6
- 3.5
- 3.4
- 3.3
- 3.2
- 3.1
- 3.0
- 2.9
- 2.8
- 2.7
- 2.6
- 2.5
- 2.4
- 2.3
- 2.2
- 2.1
- 2.0
- 1.4
- 1.3
- 1.2
- 1.1
- 1.0
- 0.9
- 0.8
- 0.7
- 0.6
- 0.5
- 0.4
- 0.3
- 0.2
- 0.1
This package is auto-updated.
Last update: 2024-09-13 20:25:27 UTC
README
微框架
Chiron 是一个 PHP 微型框架,可以帮助您快速编写简单而强大的 Web 应用程序和 API。要访问框架,只需包含自动加载器即可。
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
require_once __DIR__.'/../vendor/autoload.php';
$app = new Chiron\Application();
$app->get('/hello/[:name]', function (Request $request, Response $response, string $name) {
$response->getBody()->write('Hello ' . $name);
return $response;
});
$app->run();
接下来,我们定义一个匹配 GET 请求的 /hello/[:name] 路由。当路由匹配时,将执行函数,并将返回值作为 HTTP 响应发送回客户端。
安装
如果您想快速入门,可以使用 Chiron 框架模板作为基础,通过运行以下 bash 命令:
$ composer create-project chiron/chiron-skeleton [my-app-name]
将 [my-app-name] 替换为您新应用程序所需的目录名称。
然后您可以使用 PHP 内置的 Web 服务器运行它
$ cd [my-app-name]; php -S localhost:8080 -t public public/index.php
或者使用 Composer 快捷方式
$ composer start
如果您需要更多灵活性,只想安装框架,请使用以下 Composer 命令:
$ composer require chiron/chiron
描述
关于 Chiron
特性
- PSR-{2,3,4,6,7,11,12,15,16,17} 兼容
- 简单、快速的路由引擎.
- 强大的依赖注入容器.
动机
Chiron 的构建目的是了解主要 PHP 框架在底层是如何运作的。大多数框架,如 Laravel,实现了一些技术,如果不亲自实现,可能会觉得像“魔法”,例如利用反射 API 插入依赖项。Chiron 在使我熟悉 PHP 和 OOP 世界的一些高级概念方面帮助很大。
模板
许可证
MIT 许可证 (MIT)。有关更多信息,请参阅 LICENSE
。