getcloudcontrol/microframework

用于快速构建微服务的骨架微框架

1.2.3 2019-06-28 14:35 UTC

This package is auto-updated.

Last update: 2024-09-29 02:08:14 UTC


README

用于快速构建微服务的骨架微框架

安装

composer require getcloudcontrol/microframework

使用

推荐项目结构

建议将所有流量重定向到“public”文件夹内的索引文件,这样您的composer.json和其他项目文件可以保持在根目录,并且无法远程访问。

|
| .htaccess // Which redirects all trafic to public/index.php
| composer.json
| compsser.lock
|_ public/
|_ public/index.php
|_ vendor/

创建应用

index.php

<?php

require_once(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');
use getcloudcontrol\microframework\App;

App::prepare(__DIR__);
if (App::cliServerServeResource()) {
    return false;
}

App::run();
App::render();

本地运行

使用PHP内置服务器,使用index.php作为路由脚本

php -S localhost:3000 index.php