【问题标题】:Laravel functionality with Wordpress Admin panel带有 Wordpress 管理面板的 Laravel 功能
【发布时间】:2018-09-10 17:57:55
【问题描述】:

我正在尝试将 Wordpress 管理面板(与一些插件,如 – Yoast)和 Laravel 结合起来。主要功能(如路由、视图、主要 MVC、支付、IVR 等)将由 Laravel 处理,但还需要一些 Wordpress 插件和整个仪表板功能。

我尝试了一些方法,但大多数都过时了(2 到 3 岁),我也尝试了一些 github repos 以及 larapass,但到目前为止,我在 corcel/corcel 方面取得了一些成功,但刚刚得到了数据由 Eloquent 提供,但是否可以与 Laravel 一起访问 Wordpress 函数(例如:the_content、the_title、the_post_thumbnail)!?

【问题讨论】:

  • 有什么方法可以将 Wordpress 函数(如 - the_post_thumbnail)与 corcel 一起使用!?为此,我认为我必须为 WP DB 的每个表制作::model ,然后我必须显示它们之间的关系。因为在 Wordpress 中 - 数据库管理不太好(我认为,请不要介意)。 WP 将帖子、页面甚至特色图片作为 wp_posts 表的元素,尽管实际图片的链接将在 wp_postmeta 表中,因此我们必须建立 Eloquent 关系来为用户获取它们。我真的需要一些帮助。提前致谢。

标签: php wordpress laravel


【解决方案1】:

几年前我创建了一个实验来结合 Laravel 和 Wordpress,你可以在这里找到它:

https://github.com/darrencraig/LaraPress

您应该注意,这从未在生产中使用过,而是作为一种概念被盗用。但希望对您有所帮助。

有几件重要的事情需要注意 -

首先,Wordpress 是 Laravel 项目的一个依赖,通过 composer 加载 -

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

安装到/public/wp/目录,而Wordpress插件等安装到/public/app/

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

Laravel 的 index.php 文件已更新为首先加载一些 Wordpress 功能 -

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

一个新的 wp-config.php 文件被添加到引导 Laravel 和路由请求。第 44 行从 /bootstrap/wordpress.php 加载重要的 Wordpress 常量。您可以在 .env 文件中定义这些。

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

第 53-55 行检查请求是否为 Wordpress 请求。如果请求不是来自 /wp/ 目录(即请求不要求 Wordpress 文件),则请求由 Laravel 处理,否则由 Laravel 忽略并由 Wordpress 处理。

Corcel 已添加到项目中,您可以使用 Wordpress 功能定义单个帖子类型 - 例如 -

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

您可以浏览代码并提交以进一步了解它。

我希望这会有所帮助!祝你好运!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-18
    • 1970-01-01
    • 1970-01-01
    • 2012-12-08
    相关资源
    最近更新 更多