Presentation at Laravel London Meetup, Google Campus London, March 29th 2016. Examines examples of alternative database solutions and how they can be integrated into Laravel projects.
6. Laraval London Meetup March 2016
Sportsperson Encyclopedia SQL DB Structure
Athletics
Football
People
Cricket
migration
model
repository / service class
view
7. Laraval London Meetup March 2016
Sportsperson Encyclopedia Doc Store DB Structure
service class
view
model / repository
9. Laraval London Meetup March 2016
high availability
reliability
scalability
flexibility
affordability
What are we looking for?
“users can get at their stuff anytime”
“I don’t have to keep fixing it”
“it can grow with the business”
“working with it isn’t too expensive”
“easy to make structural changes”
10. Laraval London Meetup March 2016
Database Scaling
Horizontal ScalingVertical Scaling
12. Laraval London Meetup March 2016
Document store
Proprietary API using JSON
Client for PHP (+ almost 30 others)
Switchable storage engines
Server-side scripts in Javascript
MongoDB
13. Laraval London Meetup March 2016
Search Engine
Often used as a secondary store
Java API + RESTful API HTTP/JSON
Client for PHP (+ almost 15 others)
Indexes content by default
Server-side scripts possible (Java?)
Elastic
14. Laraval London Meetup March 2016
Key-Value Store / Document store
Proprietary RESTful API
Client for PHP (+ almost 10 others)
Hosted so no server-side scripting
Proprietary hardware
Really, really fast at scale
DynamoDB
15. Laraval London Meetup March 2016
Hosting
Local
Installation
with some
limitations
Database as
a Service
ElasticCloud
AWS ElasticSearch
AWS DynamoDB
mLab
MongoHQ
Self-managed
16. Laraval London Meetup March 2016
Install PHP driver
Add jenssegers/mongodb aka Moloquent to your project
Configure mongodb connection
Use Moloquent in place of Eloquent as your base model
Use as you would Eloquent (with extras)
Using MongoDB with Laravel
20. Laraval London Meetup March 2016
Using Elastic with Laravel
Add Elasticquent to your project
Configure connection (i.e. give it API endpoints)
Add the Elasticquent trait to your models
Populate Elastic from your primary store
Search
23. Laraval London Meetup March 2016
Using Elastic with Laravel
• totalHits
• shards
• maxScore
• timedOut
• took
24. Laraval London Meetup March 2016
Using DynamoDB with Laravel
Add aws/aws-sdk-php-laravel or baopham/laravel-dynamodb to your project
Set up .env entries for AWS “key”, “secret” and “region”
Wrap API methods in a base model or repository
25. Laraval London Meetup March 2016
Using DynamoDB with Laravel
PutItem
UpdateItem
GetItem
DeleteItem
BatchGetItem
BatchWriteItem
Query
Scan
27. Laraval London Meetup March 2016
Gotchas
Pagination
Pagination
Becoming too “Laravelised”
Unexpected exceptions
Consistency
Limits on record size
Limits on records returned
Limits on resultset size
28. Laraval London Meetup March 2016
Do consider alternatives to SQL
Be mindful as to who will support your infrastructure
Perform deep analysis on how your data is / will be used and index
Prototype important functionality
Monitor performance
Experiment and have fun
Conclusion