Reputation: 18548
oh boy... Hey guys hope all is well. I'm an iphone/ipad programmer, wanting to create a webservice with a few methods that I could then send json requests to the webservice and make it all jolly.
I'm currently trying to create a web service. This is my host: justhost.com. I understand I wont be able to setup any sort of .net framework since its all linux. I then was told i could however setup a web service with slim or epiphany. Both of which I've been told shouldn't take long at all to setup. 5 mins max? I have however spent the last 2 days trying to make things work with little success.
I stuck with Slim since, in my opinion, it has an easier setup compared with epiphany. I now am testing an hello world example so that I am then able to write something like this in my webpage....
testing.mysite.com/hello/pk
but I'm just getting blank pages. im assuming that my .htaccess file must be correct for any url i write in the address bar with a prefix of my site to not throw a incorrect error page.
This is what my folder directory looks like atm:
And i've inserted the .htaccess file that was provided by the Slim framework.
What else do i need to do to make this work. what am i missing. I hope someone can help me with this.
UPDATE 1
This is the error im receiving.. Parse error: syntax error, unexpected T_FUNCTION in /home1/dholnot1/public_html/testing/index.php on line 8 I then removed the semi colon at the end of the require statement and that changed the error to this: Parse error: syntax error, unexpected T_VARIABLE in /home1/dholnot1/public_html/testing/index.php on line 5
UPDATE 2
This is my code:
<?php
require 'Slim/Slim.php';
$app = new \Slim\Slim();
//GET route
$app->get('/hello/:name', function ($name) {
echo "Hello, $name";
});
//POST route
$app->post('/person', function () {
//Create new Person
});
//PUT route
$app->put('/person/:id', function ($id) {
//Update Person identified by $id
});
//DELETE route
$app->delete('/person/:id', function ($id) {
//Delete Person identified by $id
});
$app->run();
?>
UPDATE 3
I have upgraded php configuration to PHP Version 5.3.18 which means anonymous functions will work now.
this is the new error im getting: Fatal error: Class 'Slim\Log' not found in /home1/dholnot1/public_html/testing/Slim/Slim.php on line 242
i've checked in the slim.php file at line 242 and it reads this:
'log.level' => \Slim\Log::DEBUG,
Upvotes: 1
Views: 6470
Reputation: 6916
Use the code below:
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
//GET route
$app->get('/hello/:name', function ($name) {
echo "Hello, $name";
});
...
$app->run();
$app = new \Slim\Slim()
Upvotes: 2