Unable to call API of slim framework

别来无恙 提交于 2019-12-11 02:07:55

问题


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.

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.

Here is the 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.


回答1:


It is recommend PHP >= 5.3 to enjoy Slim's support for anonymous functions like as Get,Post,put and delete.

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.




回答2:


Upgrade your live server to support PHP 5.1, which is the minimum requirement for Slim:

  • Web server (URL rewrite module recommended)
  • PHP >= 5.1
  • libmcrypt > 2.4.x (if using encrypted cookies)

Also note that as you are using a closure in your code above you will need at least PHP 5.3 to proceed.

The version your server is running is nearly 12 years old and it is not even the last PHP4 release!!

The manual states that:

Support for PHP 4 has been discontinued since 2007-12-31.



来源:https://stackoverflow.com/questions/9278813/unable-to-call-api-of-slim-framework

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!