Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Phil Sturgeon:
Build API's That You Wont Hate: Part 1 - Useful Database Seeding
Nov 11, 2013 @ 15:19:33

Phil Sturgeon has posted the first part of a series he calls "Build API's That You Won't Hate", a follow up to one of his previous posts about building good APIs in your application.

A little while back I produced an article called Building a Decent API which was mostly a tongue-in-cheek list of things that I'd come across in other APIs that pissed me off, or that I had done myself and used my super-power of hindsight combined with sarcasm to make a set of rules for you to live by when building APIs. The combination of cheek and naughty words made that "eat your greens" article go down a lot more smoothly, but it certainly lacked a little substance but I always wanted to turn that into a much more in depth of blog posts.

In this first part of the series he covers one main topic - generating "good" data for you to use in your development environment. As he points out, using production data in development databases dangerous for several reasons. He suggests the Faker library to do what's called "database seeding" and generating fake, but accurately formatted, data to use for testing. He includes some sample code showing how to use the PHP tool to generate as set of seed user data. He also shows how to create a DatabaseSeeder class for Laravel and integrate it with the tool.

tagged: api development database seeding faker laravel

Link: http://philsturgeon.co.uk/blog/2013/11/build-apis-part-1-useful-database-seeding


Trending Topics: