The idea of Laravel Corcel is very appealing. I’ve worked on two projects with Corcel. The projects were built years apart from each other by two entirely different teams.
Corcel is a collection of PHP classes built on top of Eloquent ORM (from Laravel framework), that provides a fluent interface to connect and get data directly from a WordPress database.
You can use WordPress as the backend (administration panel) or CMS, for inserting posts, custom types, etc, and any other PHP app in the other side querying those data (as a Model layer). It’s easier to use Corcel with Laravel, but you’re free to use it with any PHP project that uses Composer.
In both situations the projects did not go as well as anticipated.
When you use Corcel you are merging two systems together. Its my experience that this goes well when the expectations of WordPress are incredibly simple. For a project to go well using this package I feel the only expectation should be that content can be written in WordPress and rendered as HTML.
These two projects taught me that when you start installing WordPress plugins in a Corcel environment, expect your dreams will quickly start to disintegrate. Gravity Forms is a simple example of a plugin that works very well in WordPress under normal conditions. However, when using Gravity Forms in Corcel there is an enormous amount of compatibility work that needs to be done to get the plugin functioning. Work such as writing a driver for Gravity Forms and then binding Gravity Forms as a singleton to the Laravel container. Gravity Forms is only one example – expect many many plugins to not behave the way you expect.
If you decide to take your project in this direction, I’d guess you should budget 4 times as many hours than if you were to do a project purely using Laravel or purely using WordPress.
Things that I would suggest instead of Corcel
- Build your application in Laravel, if you have needs for WordPress get your content through the WordPress Rest Api.
- Build your site using Sage. Sage provides a clean, efficient theme templating utilizing Laravel Blade and Acorn which is Laravel components for WordPress plugins and themes.
0 responses to “Thoughts on using Laravel Corcel in Production”