shroophp/psr 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

shroophp/psr

Composer 安装命令:

composer require shroophp/psr

包简介

A library for building PSR-compliant applications with ShrooPHP.

README 文档

README

A library for building PSR-compliant applications with ShrooPHP.

Installation

composer require 'shroophp/psr ^1.0'

Example Usage

<?php

use GuzzleHttp\Psr7\ServerRequest;
use ShrooPHP\Core\Request;
use ShrooPHP\Framework\Application;
use ShrooPHP\Framework\Request\Responses\Response;
use ShrooPHP\PSR\RequestHandler;

require 'vendor/autoload.php';

$default = new \GuzzleHttp\Psr7\Response(Response::HTTP_NOT_FOUND);
$handler = new RequestHandler($default);

$handler->apply(function (Application $app) {

	$app->path('/greeting', $app->_(function (Request $request) {

		return Response::string('Hello, world!', 'text/plain');
	}));
});

$no = $handler->handle(new ServerRequest('GET', '/'));         // 404 Not Found
$ok = $handler->handle(new ServerRequest('GET', '/greeting')); // 200 OK

Important Notes

When applying an application modifier to the request handler, it is important to specify each response indirectly as the return value of a callback (as opposed to having the response as an explicit application modifier or handler).

This is because direct modifiers and handlers are not given the opportunity to make use of the presenter associated with the application. In terms of the request handler, this means that the response cannot be buffered and hence converted into a PSR-compliant instance.

统计信息

  • 总下载量: 204
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 3
  • 推荐数: 1

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0-only
  • 更新时间: 2018-05-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固