【问题标题】:Slim Application Error (website error occurred)Slim 应用程序错误(发生网站错误)
【发布时间】:2019-07-30 21:23:29
【问题描述】:

美好的一天!我总是收到此错误“(发生网站错误。抱歉给您带来暂时的不便)。”每次我尝试在邮递员中运行我的代码时。这是我的代码。

<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

require '../vendor/autoload.php';
require '../includes/DBOperations.php';

$app = new \Slim\App;


$app->post('/createClient', function(Request $request, Response $response){

if(!haveEmptyParameters(array('lastname','firstname','midname','contactnum','emailadd','password'),$response)){

$request_data = $request->getParseBody();
$lastname = $request_data['lastname'];
$firstname = $request_data['firstname'];
$midname = $request_data['midname'];
$contactnum = $request_data['contactnum'];
$emailadd = $request_data['emailadd'];
$password = $request_data['password'];
$hash_password = password_hash($password, PASSWORD_DEFAULT);

$db = new DBOperations;

【问题讨论】:

  • 我首先建议在 slim 应用实例化中添加一个配置数组,以便显示错误,$config = ['settings' =&gt; ['displayErrorDetails' =&gt; true]]; $app = new Slim\App($config); 只需记住在使代码生效时删除配置! (或者至少关闭错误slimframework.com/docs/v3/objects/…
  • 我应该在哪里添加该配置?
  • 就在你之前$app = new Slim\App,我已经在我的第一条评论中链接了一些文档:)

标签: php api slim


【解决方案1】:

@Dale 关于添加以下 LOC 的评论有帮助:

$config = ['settings' => ['displayErrorDetails' => true]]; 
$app = new Slim\App($config);

【讨论】:

    猜你喜欢
    • 2016-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-13
    相关资源
    最近更新 更多