/php-rest-mongo

Simple PHP REST API. May be considered as example of using MongoDB with PHP.

Primary LanguagePHP

PHP MongoDB REST API

Simple PHP REST API, written for small university project. May be considered as example of using MongoDB with PHP.

Used technologies:

  • PHP 5.4
  • Composer 1.0
  • MongoDB 3.0.6
  • REST

Buzzwords/Keywords:

PHP REST API, ODM via Docrine/MongoDB, Language parsing via Standford-NLP, Fuzzy, Time-Parser.

Installation:

Clone:

$ git clone https://github.com/Inlife/php-rest-mongo.git

Install dependencies:

$ php composer.phar install

Start server:

$ php -S localhost:8080

Example Code:

<?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);
    }
}

Used libraries and frameworks: