tyler/limon

无依赖的简单PHP框架

v0.3.0 2024-06-13 02:15 UTC

This package is auto-updated.

Last update: 2024-09-13 02:59:18 UTC


README

无依赖的PHP微框架,注重简洁,帮助您快速进行原型设计和交付新的API和网站。

基本用法

<?php // example basic index.php

require_once __DIR__ . '/../../vendor/autoload.php';

(function() {
    $app = new Limon\App(
        new Limon\Kernel(
            new ActionResolver
        )
    );

    /** @var Psr\Http\Message\ServerRequestInterface $request */
    $request = captureServerRequest();

    // Reguster a handler, this can be replaced 
    // with middleware that sets the request-handler attribute
    // with a routing package
    $request = $request->withAttribute(
        'requst-handler', 
        fn(ServerRequestInterface $request) => new Response()
    );

    $res = $app->handle($request);

    Limon\emit($res);
})();

入门指南

此入门指南基于XAMPP

  1. 需要安装composer包
composer require tylersriver/limon
  1. 在Apache Web根目录下创建index.php
  2. 创建以下内容的 .htaccess 文件
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>

Limon 遵循PSR标准进行请求、响应、中间件处理,并可与任何符合标准的包一起使用。有一些默认包已连接到示例骨架应用 这里

动作

Yocto 围绕 ADR 的概念构建,包括一个基本动作接口,可用于将HTTP路由拆分为单独的对象。

路由器

容器

视图