Slim PHP Framework causing 'Fail to open page'
Question
I have set up a REST API using the Slim PHP framework, which works perfectly when using requests i.e http://mysite.com/class/id.
But when I navigate to http://mysite.com/, I get the following error in Safari:
Safari can’t open the page “http://mysite.com/”.
The error is: “cannot decode raw data” (NSURLErrorDomain:-1015)
Please choose Safari > Report Bugs to Apple, note the error number, and describe what you did before you saw this message.
Please can you tell me where I am going wrong?
include_once('config.php');
require 'Slim/Slim.php';
$app = new Slim();
$app->post('/user/create', 'create_user');
$app->get('/user/:id', 'info_user');
$app->post('/user/:id', 'update_user');
$app->delete('/user/:id', 'delete_user');
$app->post('/user/validate', 'validate_user');
$app->get('/user/:id/venues', 'venues_user');
$app->get('/user/:id/queues', 'queues_user');
$app->post('/venue', 'create_venue');
$app->post('/venue/:id', 'update_venue');
$app->delete('/venue/:id', 'delete_venue');
$app->get('/venue/:id', 'info_venue');
$app->get('/venue/:id/queues', 'queues_venue');
$app->post('/queue', 'create_queue');
$app->post('/queue/:id', 'update_queue');
$app->delete('/queue/:id', 'delete_queue');
$app->get('/queue/:id', 'info_queue');
$app->run();
Solution
When using PHPFog and Slim, you have to set the HTTP Version to 1.0 rather than 1.1.
You can do this by adding a parameter to the variable:
$app = new Slim(array('http.version' => '1.0'));
This was solved thanks to the help of the Slim framework creator!
Hope this helps someone else!
OTHER TIPS
Perhaps you need an entry such as:
$app->get('/', 'index_page');