- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试使用 ValidationErrorsMiddleware.php 类作为中间件,因此我将以下代码添加到我的 bootstrap/app.php 中:
$app->add(new App\Middleware\ValidationErrorsMiddleware($container));
将上述代码添加到我的 app.php 后出现以下错误:
Fatal error: Uncaught exception 'RuntimeException' with message 'Unexpected data in output buffer. Maybe you have characters before an opening <?php tag?' in C:\wamp64\www\authentication\vendor\slim\slim\Slim\App.php on line 552
RuntimeException: Unexpected data in output buffer. Maybe you have characters before an opening <?php tag? in C:\wamp64\www\authentication\vendor\slim\slim\Slim\App.php on line 552
以防万一,任何人都需要查看我的类和 app.php 的代码,我已将它们包含在此处
ValidationErrorsMiddleware.php
<?php
namespace App\Middleware;
class ValidationErrorsMiddleware extends Middleware {
public function __invoke($request, $response, $next) {
var_dump('middleware');
$response = $next($request, $response);
return $response;
}
}
中间件.php
<?php
namespace App\Middleware;
class Middleware {
protected $container;
public function __construct($container) {
$this->container = $container;
}
}
应用.php
<?php
session_start();
require __DIR__ . '/../vendor/autoload.php';
$app = new \Slim\App([
'settings' => [
'determineRouteBeforeAppMiddleware' => false,
'displayErrorDetails' => true,
'db' => [
// Eloquent configuration
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'phpdb',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
]
],
]);
$container = $app->getContainer();
$app->add(new App\Middleware\ValidationErrorsMiddleware($container));
require __DIR__ . '/../app/routes.php';
最佳答案
我已经解决了我的问题:
return [
'settings' => [
// Slim Settings
'determineRouteBeforeAppMiddleware' => true,
'displayErrorDetails' => true,
'addContentLengthHeader' => false,
我在设置数组中添加了值为 false 的属性 addContentLengthHeader。
但是我还是不明白这是干什么的
更新
发生此问题是因为 var_dump(middleware) 行更改了响应的内容长度。我的解决方案只是一个黑客。感谢@iKlsR 提供正确答案。
关于php - PHP Slim 3 中间件的不合理错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37293280/
.net 4.0 添加了几个与线程相关的新类:ManualResetEventSlim , SemaphoreSlim和 ReaderWriterLockSlim . Slim 版本和旧类之间有什么区
一个新的 Slim 问题 我期待以下 Slim 模板 div class="header" h2 slim head p a test example of span Slim span a
我们正在考虑使用 Slim 3 作为我们 API 的框架。我已经搜索过 SO 和 Slim 文档,但找不到问题的答案。如果我们有不同的路由文件(例如 v1、v2 等)并且如果两个路由具有相同的签名,则
我正在尝试在 Slim-lang 的列表项中嵌套第二个 ul,如下所示: div.row ul.dropdown li Dropdown Option 1
我有以下代码导致 Slim::Parser::SyntaxError : p code.inline /charge 我希望这会输出 /charge但这只会让斯林姆不高兴。 为什么? 最佳答案 使
我想在子目录中使用 Slim 3,但似乎无法加载它。所有文件都包含在子目录中,包括 composer.json。这是我的 composer.json: "require": { "slim/s
我的 Slim 项目组织如下: - app -- Acme --- Auth ---- Auth.php (handles authentication) -- config --- developm
我在我的 svelte-typescript 项目上使用 clickOutside 指令,当我将自定义事件分配给相关元素时出现此错误 Type '{ class: string; onclick_ou
我们缩小了在 Silex 和 Slim PHP 框架之间的搜索范围,以便在我们的 Apache/PHP/MySQL 服务器上路由我们的 REST API。 两者似乎都有很好的评价。 Silex 可能有
我有一个 get表格中的路线 $app->get('/redirect[/{subject}]', function ($request, $response, $args) { }); 如果我向 /
任何人都可以解释在选择使用钩子(Hook)而不是使用中间件来实现身份验证或缓存等功能时是否有任何显着的优点或缺点? 例如 - 我可以通过自定义中间件获取请求对象并设置应用程序语言变量来实现翻译功能,该
在 Slim 3 中是否有类似 Laravel 的 back() helper 来获取之前的路由名称或 uri? 它不必特定于 Slim,我只是想重定向回上一页。 谢谢:) 最佳答案 假设你想要 re
在 Slim 3 中是否有类似 Laravel 的 back() helper 来获取之前的路由名称或 uri? 它不必特定于 Slim,我只是想重定向回上一页。 谢谢:) 最佳答案 假设你想要 re
我正在学习这里的教程: https://www.simplifiedcoding.net/php-restful-api-framework-slim-tutorial-1/ 导师说下载slim在:
如何从不同的 php 页面中的另一个函数调用 slim 函数 这里是 My.php: $app->get('/list/:id',function($id) { //fill array her
很抱歉提出这样一个愚蠢的问题,但在文档中找不到它: filename.slim filename.html.slim 这似乎是一种非常适合使用的语言。我以前使用过 HAML,所以我认为这将是一个相当不
请原谅我的无知,但我只是使用 npm 安装了 jQuery,并且在 jQuery 文件之间有一个名为 jquery.slim.js 的文件,slim 是什么?我知道 min 代表缩小但 slim 对我
TailwindCSS 看起来像是一个很棒的前端工具,但我想知道如何将它与 Rails Slim 模板语言一起使用? 例如: 如果我通过 HTML2SLIM 运行它,我会得到这个建议: .bg-re
TailwindCSS 看起来像是一个很棒的前端工具,但我想知道如何将它与 Rails Slim 模板语言一起使用? 例如: 如果我通过 HTML2SLIM 运行它,我会得到这个建议: .bg-re
我想将纤薄的 textmate 包安装到 sublime2。 我去了这个链接 slim textmate bundle 我将它克隆到 pristinepackage(根据 nettuts 网站),但什
我是一名优秀的程序员,十分优秀!