Phalcon 3.2 with PHP 7 and MongoDB 3.0.15

I am trying to integrate with MongoDB but I am getting error. This is what i did: In my DI file:

use Phalcon\Mvc\Collection\Manager as CollectionManager;
use Phalcon\Db\Adapter\MongoDB\Client;
//connect to Mongo
function () use ($config) {
  $mongo = new MongoClient(
    "mongodb://" . $config->mongo->username . ":". $config->mongo->password . "@" . $config->mongo->host . ":" . $config->mongo->port

// Collection Manager is required for MongoDB
    $di->set('collectionManager', function(){
    return new CollectionManager();

I created a model:

namespace App\Models;
use Phalcon\Mvc\Collection;
class APILog extends Collection
    public $id;
    public $ip;
    public $timestamp;
    public $api;

    public function initialize()
    public function showdoc($id)
        print $id;


In my service file i tried to access this APILog class: use App\Models\Log; public function writeLog($something){ $k = new APILog($something); }

This gives me 500 error.

My folder structure goes like this:
    Abstratcontroller.php  #this extends \Phalcon\DI\Injectable
     AbstractService.php #this extends \Phalcon\DI\Injectable

Can anyone please suggest what i am missing here. I need to store the Log reports.

Could you start by activating PHP errors to get an actually clear and readable error ?

Add these two lines in your public/index.php script, below error_reporting(E_ALL) (technically the fourth line if you used phalcon-devtools to generate your project).

ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');

After that, try to refresh and paste the full error here.