Have you ever thought that you can use Laravel or any PHP framework in WordPress? Corcel can help you achieve it!
Developing website applications should be fast and fun. Of course, each application will have its own needs and life cycle.
WordPress is a powerful CMS written in PHP that you can use to create your product very quickly. However, it does not follow recent PHP changes and conventions, but you can balance this out by using it with other frameworks like Laravel.
Corcel
I think the WordPress admin panel is great. It has a bunch of plugins that allow you to quickly generate fields, post types, images, crops, and more. This is really great!
That’s why Corcel makes it easy for you to get data from your WordPress database. You just need to use Composer to install WordPress and Corcel in your PHP application framework (Laravel or other framework).
Of course we can also use MVC in WordPress!
You can build controllers, models, and views for your WordPress. Corcel creates a collection of models for you to retrieve posts, pages, menus, etc., and can even connect to different databases, one for Laravel and another for WordPress.
[ 'mysql' => [ 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'app', 'username' => 'admin' 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'engine' => null, ], 'wordpress' => [ 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'corcel', 'username' => 'admin', 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => 'wp_', 'strict' => false, 'engine' => null, ], ],
Let’s start getting what you need from the WordPress database:
take(10)->get(); $page = Page::where('post_name', 'about')->first(); return view('posts.index', compact('posts', 'page')); } // ...
Post type and custom field
I don’t know if you use Have you tried the Advanced Custom Fields Feature (ACF)? Here you can also get all the custom fields:
meta->avatar; $phone = $post->meta->phone;
You can create custom models related to custom post types:
Copy after login
For more features, you can directly View it in the GitHub (https://github.com/corcel/corcel) warehouse.
You can use Corcel with any PHP framework, even micro-frameworks like Slim, Silex. It gives you access to all WordPress admin panel data and lets you organize your project with custom routes, controllers, models, and views.
Come and give Corcel a chance. You are also welcome to give some suggestions or directly contribute code, thank you!