Simple PHP REST API, written for small university project. May be considered as example of using MongoDB with PHP.
- PHP 5.4
- Composer 1.0
- MongoDB 3.0.6
- REST
PHP REST API, ODM via Docrine/MongoDB, Language parsing via Standford-NLP, Fuzzy, Time-Parser.
Clone:
$ git clone https://github.com/Inlife/php-rest-mongo.git
Install dependencies:
$ php composer.phar install
Start server:
$ php -S localhost:8080
<?php
namespace HotelBooking\Modules;
use wapmorgan\TimeParser\TimeParser;
class DateParser {
public function __construct() {}
public function run($sentence) {
$sentence = urldecode($sentence);
$response = new \stdClass();
$response->results = [];
if (strlen($sentence)) {
$response->results = [
TimeParser::parse($sentence, 'english', true)
];
}
return json_encode($response);
}
}