A Laravel seeder for all Belgian cities + postal codes

Joris Hens

Sep 11, 2014 · 1 min read

Hi! I'm GoodBytes. Web developer, teacher and souschef.

Just the other day I needed a quick seeder to populate a table in my Laravel project with Belgian postal codes. A quick search gave me all the data in XLS or XML format that would have been easy to import into MySQL, but I really wanted the data to be seeded through Laravel instead. That way, it's much easier to push the seeder to git and migrate all tables on a server or other machine in the future.

I thought it could be useful to other developers in Belgium as well, so here you go, a simple Laravel seeder for Belgian postal/zip codes, together with the city name and province it belongs to.

1 - Get the code on Github

https://github.com/iamgoodbytes/laravel-seeder-belgian-cities

2 - Run artisan

Run artisan migrate:refresh --seed to re-run all your migrations and seed the tables. If all goes well you will now have a table with all Belgian cities and their zip codes.

Belgian Postal Codes

3 - Troubleshooting

I can't think of much that can go wrong here, but if for some reason the seeder doesn't work for you, make sure you run composer dump-autoload to update the list of classes to load in order to include the seeder class. If it still fails, get in touch with me and I'll see what I can do! Keep on coding!

« Upgrading from CentOS 6 to CentOS7? Here are some gotchas
Keep on reading
Userful tools and workflow tips for building mobile apps in HTML, CSS and Javascript »