June 26th, 2024

Corcel – Use WordPress backend with Laravel or any PHP application

Corcel is a PHP package integrating WordPress databases with Laravel's Eloquent ORM. It supports various WordPress features, enhancing data retrieval for PHP projects. Inquiries for specific details are welcome.

Read original articleLink Icon
Corcel – Use WordPress backend with Laravel or any PHP application

The GitHub URL provided contains information about Corcel, a PHP package designed to interact with WordPress databases using Eloquent ORM from Laravel. Corcel offers a fluent interface for data retrieval, compatible with Laravel and other PHP projects utilizing Composer. It supports various WordPress features like Posts, Advanced Custom Fields (ACF) Integration, Custom Post Types, Taxonomies, Pages, Categories & Taxonomies, Attachments & Revisions, Thumbnails, Options, Menu, Users, Authentication, and more. This package facilitates seamless data retrieval and manipulation from WordPress databases, enhancing the functionality of PHP projects. For further details or specific inquiries regarding Corcel's capabilities, additional information can be provided upon request.

Link Icon 18 comments
By @dizaime - 4 months
Corcel has worked great for us, even in a production environment.

Our family's e-commerce business previously had a slow and bloated WooCommerce site, largely due to my skill issues. However, we were able to rescue the site by using Corcel, Laravel, Filament, and LunarPHP.

My wife still uses the WordPress admin interface as the main admin tool, while the public-facing website is rendered by Laravel, with data provided seamlessly through Corcel.

By @hu3 - 4 months
If I understood correctly, this is basically a collection of Eloquent (Laravel's ORM) models that represent Wordpress database tables.

Nifty tool for PHP projects that need to interface with Wordpress data.

With how large the Wordpress market is, this is probably desired by more teams than one could think of at a quick glance.

By @crooked-v - 4 months
I can see why people would do this with existing WordPress setups, but would there be any reason to consider it for a new build over a dedicated headless CMS (like Strapi or a bunch for PHP I don't know well enough to name) or headless CMS SAAS (like Prismic)?
By @woody311 - 4 months
I haven't used Corcel as I haven't needed to reach for Eloquent but https://github.com/roots/acorn and the ecosystem surrounding it is fantastic.
By @saltybytes - 4 months
How's Corcel different to using WP's own API? What are the pros / cons?
By @philipwhiuk - 4 months
This is a good mid-migration step but I'm not sure the WP database design is of particular merit otherwise.

(This is speaking as someone who just migrated a site TO WordPress because it was still better than the previous system...)

By @ssnepenthe - 4 months
There is also wordpress-interop on the doctrine side: https://github.com/williarin/wordpress-interop
By @chiefalchemist - 4 months
Can someone explain the sweet spot here? WP has a REST API. It has a GraphQL plugin. Whether you use those via BE or FE requests, the backend is already open to anything.
By @jackconsidine - 4 months
This is very cool! It always felt like PHP was behind in tooling - git-driven CI was challenging for WordPress (because the framework's plugins edit the project files and it is married to subversion), and serverless PHP was basically impossible until Laravel Vapor came along. Projects like this give me hope and excitement. I wish Corcel was around years ago when I had to write gross SQL string interpolation for various WordPress projects.
By @aantix - 4 months
Interesting.. Is there a Ruby/rails equivalent?
By @moritzwarhier - 4 months
Curious about the name choice!

Is it derived from "coerce", because it can be pronounced like "core cell"? Or something else? Or just a made-up term? :)

Could imagine people being genuinely grateful for being able to plug another PHP application onto WordPress for the frontend, if this works well.

Great idea!

By @localfirst - 4 months
if this works it would completely change how we do things with wordpress.

1. does it work with any wordpress plugin? can i piggy back off laravel + frankenphp to scale what used to be nightmarish with wordpress?

2. does the underlying CMS UI still work for WP? Or is it built separately?

By @aussieguy1234 - 4 months
Ive had success previously using Symfony talking to the WordPress database.

Later, I used React to talk to the WordPress API, exposing the Customiser config as JSON, then getting React to render pages based of this.

By @hparadiz - 4 months
I've had to do this manually so many times over the years.
By @Implicated - 4 months
Have been using this for years to handle the auth in a Laravel application that's tucked inside of a WooCommerce shop, works great.
By @ulrischa - 4 months
Useless. WP has a very good REST API
By @benatkin - 4 months
Better than using Gatsby, which adds complexity both on the node point javascript and WordPress end of things: https://www.gatsbyjs.com/plugins/gatsby-source-wordpress/

Either are better than having to deal directly with WordPress, though.

By @tcfunk - 4 months
Anyone know of something similar but for interfacing with a Drupal database?