简体   繁体   中英

Laravel functionality with Wordpress Admin panel

I am trying to combine Wordpress admin panel(with some plugins like – Yoast) and Laravel. Main functionalities(like – Routing, views, Main MVC, Payment, IVR etc) will be handled by Laravel but also want some plugins of Wordpress in work and whole Dashboard functionality.

I have tried some ways but most of them are out dated (2 to 3 years old) , I have also tried some github repos as well like larapass but so far I have a little success with corcel/corcel but just got the data by Eloquent but is there anyway to access Wordpress functions (eg: the_content, the_title, the_post_thumbnail) along with Laravel!?

I created an experiment a couple of years ago to combine Laravel and Wordpress, which you can find here:

https://github.com/darrencraig/LaraPress

You should note that this was never used in production and was hacked together as a rpoof of concept. But hopefully it helps you.

There are a couple of important things to notice -

First, Wordpress is a dependancy of the Laravel Project, loaded through composer -

https://github.com/darrencraig/LaraPress/blob/master/composer.json#L10

It is installed to the /public/wp/ directory, while Wordpress plugins, etc are installed to /public/app/

https://github.com/darrencraig/LaraPress/blob/master/composer.json#L62

Laravel's index.php file has been updated to load in some Wordpress functionality first -

https://github.com/darrencraig/LaraPress/blob/master/public/index.php

A new wp-config.php file is added to bootstrap Laravel and route requests. Line 44 loads the important Wordpress constants from /bootstrap/wordpress.php. You can define these in your .env file.

https://github.com/darrencraig/LaraPress/blob/master/public/wp-config.php

Lines 53-55 check to see if the request is a Wordpress request. If the request does not come through the /wp/ directory (ie the request does not ask for a Wordpress file) the request is handled by Laravel, otherwise it ignored by Laravel and handled by Wordpress.

Corcel has been added to the project and you can define individual post types using Wordpress functions - for example -

https://github.com/darrencraig/LaraPress/tree/master/app/News https://github.com/darrencraig/LaraPress/blob/master/app/News/NewsServiceProvider.php https://github.com/darrencraig/LaraPress/blob/master/app/News/News.php

You can browse through the code and commits to understand it more.

I hope this helps! Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM