DEV Community

spO0q
spO0q

Posted on

2 1

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).

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay