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:
- Serve the application with
php artisan serveor Valet.
- Seed the database with data fixtures by running
php artisan migrate --seed.
- Get an overview of the
api/v1routes by running
php artisan route:list.
- Download the Postman collection here and import the file into your Postman client.
- Start testing (and remember to change environment variables as needed).
- PHP v7.x
- MongoDB v3.4
- nginx 1.10 or PHP's built-in web server
I'm having issues installing the
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.
Class 'MongoDB\Driver\Manager' not foundwhen 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:
- The inability to drop tables using
- Missing polyfills on its drop-in Eloquent replacement.
- The inability to use a table's
idcolumn on the default query builder; you'll have to use
_id-- the convention with which MongoDB stores primary keys. This has given me problems with validation rules:
'post_id' => 'in:posts,id'
'post_id' => 'in:posts,_id'
I initially wanted to test polymorphic relationships with the
Comment models, but just went with a many-to-many due to the lack of documentation.
Why aren't you using
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.
- Integration tests
- Front-end / templates
For a comprehensive list of to-dos for the core functionality of the application, visit the Core features project page.