在CakePHP中集成Wordpress CMS [英] Integrate Wordpress CMS in CakePHP

查看:216
本文介绍了在CakePHP中集成Wordpress CMS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在CakePHP 2.6.1中集成Wordpress 为我的最终用户使用它作为CMS
我包含访问wordpress函数所需的文件: wp-blog-header.php



因为CakePHP只允许包含位于CakePHP内部的文件,我把wordpress intallation放在 app / Vendor / wordpress 里,现在我想导入necesary文件到我的 AppController 以这种方式:

  App :: import 'wordpress'.DS.wp-blog-header'); 

但是似乎有一些功能冲突,因为我从CakePHP得到这个错误:


错误:无法重新声明__()(以前在/home/todopeta/alvarotrigo/pruebas/cakephp/lib/Cake/basics.php:581中声明)

文件:/home/todopeta/alvarotrigo/pruebas/cakephp/app/Vendor/wordpress/wp-includes/l10n.php

Line:163

$ b $



有人在CakePHP中整合了wordpress吗?

>

我看过似乎可能与其他PHP MVC frameworksk如Laravel
CakePHP在这方面限制更多?

解决方案

通过为CakePHP创建一个WP插件来访问WP数据,每个WP表的模型,并通过CakePHP读取数据。



你的链接文章也是这样,但它使用WP_Query类,进一步下降Corcel,似乎是在口才ORM和WP之间的混合。我不会走这条路径,并使用CakePHP ORM。



我可以保证,一切都会成为一个痛苦的后方,由于fugly WP代码和



如果你尝试使用CakePHP中的WP代码,就像你试过的,这将变得超级痛苦,耗时,可能永远不会正常工作,没有一些真正真的fugly代码。



如果你只需要WP的部件考虑创建一个WP插件,并通过iframe在你的页面嵌入WP内容。 AFAIK WP得到了一个json API以及这些天,你可以尝试通过该API读取数据。


I'm trying to integrate Wordpress in CakePHP 2.6.1 to use it as a CMS for my end users. I'm including the required file to access wordpress functions: wp-blog-header.php.

As CakePHP only allows to include files located inside CakePHP I placed the wordpress intallation inside app/Vendor/wordpress and now I'm trying to import the necesary file in my AppController in this way:

App::import('Vendor', 'wordpress'.DS.'wp-blog-header');

But it seems there's some functions conflict as I'm getting this error from CakePHP:

Error: Cannot redeclare __() (previously declared in /home/todopeta/alvarotrigo/pruebas/cakephp/lib/Cake/basics.php:581)
File: /home/todopeta/alvarotrigo/pruebas/cakephp/app/Vendor/wordpress/wp-includes/l10n.php
Line: 163

Has anybody integrated wordpress in CakePHP before?

What's the way to go for it?

I've seen it seems to be possible with other PHP MVC frameworksk such as Laravel. Is CakePHP more restrictive in this respect?

解决方案

Access the WP data by creating a WP plugin for CakePHP and add a model for each of the WP tables and read the data via CakePHP.

Your linked article does the same but it uses the WP_Query class and further down Corcel which seems to be a mix between the Eloquent ORM and WP. I would not go that path and use the CakePHP ORM.

I can guarantee you that everything else is going to become a pain in the rear thanks to the fugly WP code and architecture.

If you try to use the WP code inside CakePHP like you've tried this will become super painful, time consuming and probably never work right without some really really fugly code.

If you need only parts from WP consider creating a WP plugin and embedd the WP content via an iframe in your page. AFAIK WP got a json API as well these days, you could try to read the data via that API as well.

这篇关于在CakePHP中集成Wordpress CMS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆