Zend 框架和 WordPress 集成

发布于 2024-09-25 02:44:05 字数 734 浏览 2 评论 0原文

我们有一个现有的 Zend Framework 网站托管在 ourdomain.com 上,还有一个 WordPress 博客位于 blog.ourdomain.com

我们希望将博客迁移到 ourdomain.com/blog 网站上 - 但我似乎已经用 google 搜索到了地球的尽头并且不知道如何。我尝试过各种 .htaccess 的东西,设置博客控制器并包含一些 wordpress 文件等 - 但无济于事。

有人有什么想法吗?

虚拟主机设置:

ServerAdmin [email protected]
DocumentRoot "/Users/bradyeager/Sites/TWPZend/public"
ServerName twps
ErrorLog "logs/twps-error-log"
CustomLog "logs/twps-access_log" common

期权指数 FollowSymLinks

AllowOverride All

Order allow,deny
Allow from all

We have an existing Zend Framework site hosted at ourdomain.com and a wordpress blog at blog.ourdomain.com

We want to migrate the blog into the site at ourdomain.com/blog - but I seemed to have googled to the end of the earth and cannot find out how. I have tried various .htaccess stuff, setting up a blog controller and including some wordpress files, etc - but to no avail.

Does anyone have any ideas?

Virtual host setup:

ServerAdmin [email protected]
DocumentRoot "/Users/bradyeager/Sites/TWPZend/public"
ServerName twps
ErrorLog "logs/twps-error-log"
CustomLog "logs/twps-access_log" common

Options Indexes FollowSymLinks

AllowOverride All

Order allow,deny
Allow from all

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

余生再见 2024-10-02 02:44:05

实现此目的的最有效、最简单的方法是修改 .htaccess 文件,不要将任何以 /blog 开头的内容发送到 ZF 应用程序 - 只需将其传递到 Wordpress。当然,Wordpress 必须安装在您的文档根目录中,才能正常工作,就像您通常安装它一样。

举个例子:

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

RewriteRule ^blog - [NC,L]

RewriteRule ^.*$ index.php [NC,L]

所有这些关于在 ZF 应用程序中创建自定义控制器、操作和路线,然后通过您的应用程序传递到 Wordpress 的废话绝对是荒谬的。您将执行应用程序引擎的完整调度周期,只是为了转发到另一个应用程序?

The most efficient and easiest way to accomplish this by modifying your .htaccess file to NOT send anything that starts with /blog to the ZF app -- just pass it through to Wordpress. Wordpress would have to be installed inside your document root, of course, for this to work, exactly how you would normally install it.

An example:

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

RewriteRule ^blog - [NC,L]

RewriteRule ^.*$ index.php [NC,L]

All this nonsense about creating custom controllers, actions and routes in your ZF app, then passing off to Wordpress via your app is absolutely ridiculous. You'd be executing a full dispatch cycle of your application's engine, just to forward off to another app?

荒人说梦 2024-10-02 02:44:05

实际上,我经常使用此配置,这就是我所做的:

 /application
 /library
     /Zend 
     /wordpress ( symlink to my wordpress folder )
 /public
     index.php ( i add wordpress & the zend folder to my include path )

不可否认,这是一个有点残酷的解决方案,考虑到该过程中包含的所有不必要的东西......

编辑:

// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    realpath(APPLICATION_PATH . '/../library/wordpress'),
    get_include_path(),
)));

//Get the wordpress environment
define('WP_USE_THEMES', false);
require_once 'wp-blog-header.php';

/** Zend_Application */
require_once 'Zend/Application.php';  



// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV, 
    APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
            ->run();

I often use this configuration actually , here's what I do:

 /application
 /library
     /Zend 
     /wordpress ( symlink to my wordpress folder )
 /public
     index.php ( i add wordpress & the zend folder to my include path )

Admittedly a bit of a brutal solution , considering all the unnecessary stuff that's included in the process...

Edit:

// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    realpath(APPLICATION_PATH . '/../library/wordpress'),
    get_include_path(),
)));

//Get the wordpress environment
define('WP_USE_THEMES', false);
require_once 'wp-blog-header.php';

/** Zend_Application */
require_once 'Zend/Application.php';  



// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV, 
    APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
            ->run();
秋风の叶未落 2024-10-02 02:44:05

关于将非 ZF 站点迁移到 ZF 的最佳文章之一来自 Chris Abernethy。

和您一样,他为那些非 ZF 处理的脚本设置了一个特殊的控制器。然而,他(最终)设置了与那些非 ZF 页面相对应的 ZF 路由,而不是使用外部 .htaccess。

可能不适用于您的案例,因为您的示例涉及子域,而他的示例涉及同一域上的页面。但其中有一些好主意可能会有所帮助。

One of the best articles about migrating a non-ZF site into ZF is from Chris Abernethy.

Like you, he sets up a special controller for those non-ZF handled script. However, he (eventually) sets up ZF-routes corresponding to those non-ZF pages, rather than playing around with external .htaccess.

Might not apply directly to your case, since your example involves a subdomain while his involves pages on the same domain. But there are some good ideas in there that might be helpful.

小苏打饼 2024-10-02 02:44:05

请参阅 Jason 提供的正确答案。只需确保您的 wordpress .htacess 文件重写为正确的 index.php 默认情况下,它将重写回属于 Zend 的基本 index.php。我的解决方案是将 Wordpress 的 .htaccess RewriteBase 更改为 /blog 而不是 /

See the correct answer provided by Jason. Just make sure your wordpress .htacess file is rewriting to the correct index.php By default, it will rewrite back to the base index.php - which belongs to Zend. My solutions was to change Wordpress' .htaccess RewriteBase to /blog instead of /

叫思念不要吵 2024-10-02 02:44:05

我编写了一个名为 Vulnero 的开源库,它可以解决您的问题,它允许您在 WordPress 中运行 Zend Framework 应用程序。您的路线由您的应用程序处理,其他一切都交给 WordPress。如果您愿意,甚至可以在 WordPress 模板中呈现您的视图。集成身份验证、数据库连接等等。源代码位于 GitHub 上,或者您可以阅读 http://www.vulnero.com/ 上的文档。

I wrote an open source library that might solve your problem called Vulnero that allows you to run your Zend Framework application inside WordPress. Your routes get handled by your app, everything else goes to WordPress. Can even render your views in your WordPress template if you like. Integrates authentication, database connections, all that. Source is on GitHub or you can read the documentation at http://www.vulnero.com/.

锦爱 2024-10-02 02:44:05

要将 Wordpress 迁移到 ZF,您可以使用 wploader
当我使用 WordPress 启用多个站点时,这对我有用。
您可以在 WordPress 文件中使用所有 ZF 控制器对象。
您不需要对您的 WordPress 进行任何修改,因此您可以轻松升级或更新您的 WordPress 版本。

For migrating Wordpress into ZF you can use wploader.
This works for me when i use wordpress as multiple site enabled.
You can use all ZF controller objects inside your wordpress files.
You don't need any hack in your wordpress , so you can upgrade or update your wordpress version easily.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文