Home

Awesome

Mongoblog

Laravel feat. MongoDB

A simple, proof-of-concept Laravel blog application powered by a MongoDB ORM.

Separated API and front-end

This is a RESTful application, whose API is entirely decoupled from its front-end (neat, eh?), meaning it is fully testable from a REST client like Postman or from PHPStorm's built-in client.

To test the API endpoints on Postman:

  1. Serve the application with php artisan serve or Valet.
  2. Seed the database with data fixtures by running php artisan migrate --seed.
  3. Get an overview of the api/v1 routes by running php artisan route:list.
  4. Download the Postman collection here and import the file into your Postman client.
  5. Start testing (and remember to change environment variables as needed).

System requirements

Gotchas

I'm having issues installing the jenssegers/mongodb package.

Run php -m | grep mongodb to confirm that the MongoDB PHP extension is installed.

If the above does not work, run composer install --ignore-platform-reqs.


I'm getting Class 'MongoDB\Driver\Manager' not found when I run the application

Restart your web server. It probably has not loaded the php-mongodb extension yet.

Can I revert back to MySQL/SQLite without issue?

Unfortunately, as this library is not officially supported by Laravel, it comes with integration issues here and there, a few which are:

I initially wanted to test polymorphic relationships with the Category and Comment models, but just went with a many-to-many due to the lack of documentation.


Why aren't you using Route::dispatch() or app()->handle() to consume internal API endpoints?

Taylor Otwell advises against using sub-requests to make internal API calls, as they mess the current route. I went with this kitetail/zttp package by Adam Wathan that leverages Guzzle and I wrapped it within a trait.

Features & suggestions

View the Projects page for a roadmap of things to come.

If you come across a bug, feel free to open a new issue. For a bug specific to the MongoDB ORM, submit a ticket via their GitHub page.

To-do

For a comprehensive list of to-dos for the core functionality of the application, visit the Core features project page.