DEV Community

spO0q 🐒🎃
spO0q 🐒🎃

Posted on

What can Corcel bring to WordPress?

I'm not a fan of "big crossovers" in Tech. It often turns bad, especially with WordPress, as people like to hack it in the worst possible ways.

However, Corcel might have some lessons to teach, as it did not try to break/control the beast (a.k.a. WordPress) but provided a nice object-oriented PHP interface to interact with the WordPress database instead.

Download the code

It's here, but you may prefer Composer, the package manager for PHP:

composer require jgrossi/corcel
Enter fullscreen mode Exit fullscreen mode

Headless WordPress with PHP?

I see many pros for such approach. Here are some majors points:

  • the authors took the time to understand WordPress and its ecosystem*s* (e.g., advanced compatibility with WordPress menus, taxonomies, or major plugins like ACF)
  • provides a universal Model layer for any other PHP app that want to interact with the WordPress backend (not just Laravel)
  • very convenient syntax: Post::status('publish')->get();

The big caveat

The project does not seem to be particularly active, as the last release was in February 2022 (at the time of writing).

There might be some issues, especially with the latest versions of Laravel. Although, it's still a nice alternative to consider for a custom PHP project, IMHO.

Wrap up

WordPress has its strengths and still powers most websites.

People (and organizations) love it as a backend platform, but it does not mean you have to stick with its templating system.

JavaScript devs can already interact with the built-in JSON API to build fancy experiences, but PHP interfaces like Corcel remain quite misknown, regardless of their success (Corcel is very popular on GitHub).

Top comments (0)