简体   繁体   English

无法调用苗条框架的API

[英]Unable to call API of slim framework

I am designing an API in PHP using slim framework. 我正在使用苗条框架在PHP中设计API。 These are working fine on my local system and my public IP. 这些在我的本地系统和公共IP上运行良好。 But now I upload these APIs files on to my company server. 但是现在我将这些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,但是这些页面显示为空页面,这意味着我无法调用API。

Here is the 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. 这在本地正常工作,但是当我要访问公司服务器时未显示任何内容。

It is recommend PHP >= 5.3 to enjoy Slim's support for anonymous functions like as Get,Post,put and delete . 建议使用PHP> = 5.3,以享受Slim对诸如Get,Post,put和delete之类的匿名函数的支持。

So if we want to make APIs using SLIM framework we need to update our PHP>=5.3. 因此,如果要使用SLIM框架制作API,则需要更新PHP> = 5.3。 Then your APIs like as Get and Post will work successfully. 然后,您的API(例如Get和Post)将成功运行。

Upgrade your live server to support PHP 5.1, which is the minimum requirement for Slim : 升级实时服务器以支持PHP 5.1,这是Slim的最低要求:

  • Web server (URL rewrite module recommended) Web服务器(建议使用URL重写模块)
  • PHP >= 5.1 PHP> = 5.1
  • libmcrypt > 2.4.x (if using encrypted cookies) libmcrypt> 2.4.x(如果使用加密的cookie)

Also note that as you are using a closure in your code above you will need at least PHP 5.3 to proceed. 还要注意,由于您在上面的代码中使用了闭包 ,因此至少需要PHP 5.3才能继续。

The version your server is running is nearly 12 years old and it is not even the last PHP4 release!! 您的服务器正在运行的版本已使用了将近12年 ,它甚至不是最新的PHP4版本!

The manual states that: 该手册指出:

Support for PHP 4 has been discontinued since 2007-12-31. 自2007年12月31日起不再支持PHP 4。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM