无法调用slim框架的API [英] Unable to call API of slim framework
问题描述
我正在使用超薄框架在 PHP 中设计 API.这些在我的本地系统和我的公共 IP 上运行良好.但现在我将这些 API 文件上传到我公司的服务器上.
I am designing an API in PHP using slim framework. These are working fine on my local system and my public IP. But now I upload these APIs files on to my company server.
现在我正在尝试访问存储在我公司服务器上的 API,但这些页面显示的是空页面,这意味着我无法调用 API.
Now I am trying to access API stored on my company's server but these are showing empty pages, this means I am unable to call API.
这里是 API
<?php
include('connect.php');
header('Content-type: text/xml');
header('Content-type: application/json');
// Include the Slim library
require 'Slim/Slim.php';
// Instantiate the Slim class
$app = new Slim();
$app->get('/', function () {
echo "Pericent is working on Campus Concierge...";
});
$app->run();
?>
这在本地工作正常,但是当我想访问公司服务器时它没有显示任何内容.
This is working correctly locally, but it is not showing anything when I want to access company server.
推荐答案
建议 PHP >= 5.3 享受 Slim 对匿名函数的支持,例如 Get、Post、put 和 delete.
It is recommend PHP >= 5.3 to enjoy Slim's support for anonymous functions like as Get,Post,put and delete.
所以如果我们想使用 SLIM 框架制作 API,我们需要更新我们的 PHP>=5.3.然后,您的 API(如 Get 和 Post)将成功运行.
So if we want to make APIs using SLIM framework we need to update our PHP>=5.3. Then your APIs like as Get and Post will work successfully.
这篇关于无法调用slim框架的API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!