Author: Junior Grossi
Posted on: 2016-06-07
Package: Corcel (Laravel + WordPress)
WordPress is certainly the most popular PHP application ever. However, many PHP developers do not like to develop on top of its code because it is in great part not based on object oriented code and does not follow the latest PHP framework trends.
Nowadays many developers love newer frameworks like Laravel to build their applications.
The Corcel framework brings the two worlds: WordPress and Laravel or other modern frameworks.
Read this article to learn how you can use the Corcel framework to build applications on the top of WordPress backend.
Nowadays many developers love newer frameworks like Laravel to build their applications.
The Corcel framework brings the two worlds: WordPress and Laravel or other modern frameworks.
Read this article to learn how you can use the Corcel framework to build applications on the top of WordPress backend.
Contents
Introduction
What is Corcel?
What you need to use Corcel?
So can I use MVC with WordPress?
Post Type and Custom Fields
Conclusion
Introduction
What is Corcel?
What you need to use Corcel?
So can I use MVC with WordPress?
'connections' => [ 'mysql' => [ // this is your Laravel database connection 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'app', 'username' => 'admin' 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'engine' => null, ], 'wordpress' => [ // this is your Corcel database connection, where WordPress tables are 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'corcel', 'username' => 'admin', 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => 'wp_', 'strict' => false, 'engine' => null, ], ],
Post Type and Custom Fields
Do you use Advanced Custom Fields (ACF)? You can get all the custom fields too:
<?php // ... $post = Post::find(1); $avatar = $post->meta->avatar; $phone = $post->meta->phone;
You can create custom models related to custom post types:
<?php // ... use Corcel\Post as Corcel; class Service extends Corcel { protected $postType = 'service'; }
Conclusion
There are many more features you can check directly in the package README file.
You can use Corcel with any PHP framework, even micro frameworks like Slim, Silex, etc.. It allows you to get all WordPress administration panel data and gives you the opportunity to organize your project using custom routes, controllers, models and views.
Give Corcel a try, suggest new features and contribute. You are welcome!
You need to be a registered user or login to post a comment
1,392,680 PHP developers registered to the PHP Classes site.
Be One of Us!
Login Immediately with your account on:
Comments:
1. Nice One - Lucky Chauhan (2016-06-07 11:21)
I really liked it.... - 0 replies
Read the whole comment and replies