Fresa is a better way to develop WordPress
I built Fresa, a library that makes WordPress development more enjoyable using object-oriented standards and fluent, expressive interfaces.
I built and released Fresa – a library for making WordPress development enjoyable.
Check out the screencast above for a quick demo!
In Rails, you can define instances of
And in Laravel, you can define instances of
I’m originally a WordPress developer. But when I come back to WordPress now, I’m reminded of how much work it takes to do simple things, like:
- Remember what method to use:
- Create and retrieve posts with different methods:
- Set post meta on an object which should be a first-class data citizen. I’m required to use
update_post_meta($event_id, 'foo', 'bar')and
get_post_meta($event_id, 'foo', true)
WordPress is a complex and mature piece of software – and it’s no surprise that its API patterns have drifted over a literal decade. I’m often reminded of the website PHP Sadness, which highlights some of the consistencies in PHP’s core methods. I feel the same way sometimes about WordPress.
After watching Things Laravel Made Me Believe by Jeffrey Way at Laracon EU 2015, I was inspired to plant my feet and create a better way to develop WordPress.
So I did. And that’s the motivation behind Fresa!
It all starts with the Model class:
After defining your first model, you have a ton of power at your fingertips. A custom post type registration, which normally requires nearly 60 lines of code, can be done in just a couple lines!
In WordPress, creating instances of custom post types with related metadata can be tedious, requiring several functions and different parameters.
With Fresa, you can rely on an expressive, object-oriented pattern to create objects:
The same goes for fetching objects! Here’s a comparison of fetching single models in addition to querying for models using Fresa:
Fresa does a ton of other cool things, too. Check out the Fresa documentation to learn more.
I hope Fresa is useful to you. I’ve already included it in a production application, and I’m excited to find other ways to use it.