Pergunta

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.

Foi útil?

Solução

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.

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top