httpsoft/http-app

HTTP 软件应用模板

1.1.0 2023-05-05 23:05 UTC

This package is auto-updated.

Last update: 2024-09-22 00:23:15 UTC


README

License Latest Stable Version Total Downloads GitHub Build Status GitHub Static Analysis Status Scrutinizer Code Coverage Scrutinizer Code Quality

这是一个用于快速创建简单但功能强大的 Web 应用程序和 API 的 HTTP 应用程序模板。“开箱即用”,应用程序模板已配置为与 JSON 一起工作,以实现快速 REST API 开发。

此应用程序模板的核心是 httpsoft/http-basis 微框架。默认情况下,还使用了实现 PSR-11devanych/di-container 和实现 PSR-3monolog/monolog 日志记录器。您可以轻松地将容器和记录器更改为您首选的 PSR 实现方式。

文档

安装

此项目模板需要 PHP 版本 7.4 或更高版本。

composer create-project --prefer-dist httpsoft/http-app <app-dir>

要验证安装,请转到 <app-dir> 并启动 PHP 内置的 Web 服务器

cd <app-dir>
composer run serve

之后,在您的浏览器中打开 http://localhost:8080

测试和检查

以下命令在应用程序目录中运行

  • composer run test — 运行测试。
  • composer run static — 运行静态代码分析。
  • composer run cs-check — 运行编码标准检查。
  • composer run cs-fix — 运行违反编码标准的自动纠正。
  • composer run check — 运行编码标准检查、静态代码分析和测试。

目录结构

默认情况下,应用程序模板具有以下结构

bin/                  Executable console scripts.
    chmod-var.php     Recursively changing the "var/" directory mode.
config/               Configuration files.
    config.php        Main configuration.
    container.php     Dependency injection.
    pipeline.php      Middleware pipeline.
    routes.php        HTTP request routes.
public/               Files publically accessible from the Internet.
    index.php         Entry script.
src/                  Application source code.
    Http/             HTTP application classes (actions, middelware, etc.).
    Infrastructure/   Helper classes (factories, listeners, etc.).
    Model/            Domain model classes (entities, repositories, etc.).
tests/                A set of tests for the application.
vendor/               Installed Composer packages.
var/                  Temporary files (logs, cache, etc.).

您可以根据需要更改应用程序模板的结构。