douwu7168 2018-06-08 22:24
浏览 33

Slim 3 Framework路径错误 - 找不到页面

I'm trying to create a web service here using Slim3 with PHP and mySQL. When I try to connect to this web service, the browser and my postman return "Page not Found"

Here is my index.php

$app->get('/teste', function (Response $response) use ($app) {
$response->getBody()->write("Fuck off");
return $response; });

$app->post('/createuser' , function () use ($app)  {
verifyRequiredParams(array('first_name', 'last_name', 'username', 'password'));
$response = array();
$first_name = $app->request->post('first_name');
$last_name = $app->request->post('last_name');
$username = $app->request->post('username');
$password = $app->request->post('password');
$db = new DbOperation();
$res = $db->createUser($first_name, $last_name, $username, $password);
if($res == 0) {
    $response["error"] = false;
    $response["message"] = "User created";
    echoResponse(201, $response);
} else if($res == 1) {
    $response["error"] = true;
    $response["message"] = "Oops, error while creating a user";
    echoResponse(200, $response);
} else if($res == 2) {
    $response["error"] = true;
    $response["message"] = "E-mail already exist";
    echoResponse(200, $response);
} });

Here is my .htaccess

RewriteEngine On 
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d 
RewriteRule ^ index.php [QSA,L]

I know the problem is not the apache because I created a php file inside the directory and works fine.

Can anyone helps me?

Thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
    • ¥15 帮我写一个c++工程
    • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
    • ¥15 关于smbclient 库的使用
    • ¥15 微信小程序协议怎么写
    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?