将wordpress添加到现有的ZF Web应用程序 - 在哪里安装?

时间:2014-06-07 13:59:21

标签: wordpress zend-framework zend-framework2

我已启动并运行ZF Web应用程序。现在我们计划将博客添加到我们的网络应用程序中。我正在考虑使用WP博客,因为完成博客系统的时间紧迫。注意:我不打算将我的ZF应用转换为WP应用。

关于如何在谷歌上集成ZF和wordpress没什么关系,所以在我安装WP之前,我想确保我走在正确的道路上。所以这就是我到目前为止通过查看我在互联网上发现的一些文章而学到的东西。

我的ZF目录结构如下所示:(这只是原始结构)

trunk /
    module /
        app /
            (contains controller, view, model)
    public /
        css
        js
    vendor / 
        ZF

1)在ZP app中创建一个新目录(比如说www.domain.com/blog)
2)在博客目录下上传并安装WP 3)将以下标题添加到所有PHP页面。

<?php 
/* This make the magic: */
define('WP_USE_THEMES', false);
require('path-to-the-file/wp-blog-header.php');

我的问题是我应该在哪里创建博客文件夹并上传/安装WP?它会在视图文件夹下吗?还是在公共文件夹中?另外,我需要在根索引文件中包含哪些内容进行路由?

这是我的index.php文件,它们位于公共文件夹

<?php
/**
 * This makes our life easier when dealing with paths. Everything is relative
 * to the application root now.
 */
chdir(dirname(__DIR__));

function debug( $data ) {
    try {
        throw new Exception();
    } catch( Exception $e ) {
        $trace  = $e->getTrace();
        $desc = array_shift($trace);
        $info = $desc['file'].' on line '.$desc['line'].'';
        $infoS = basename($desc['file']).'('.$desc['line'].')';
    }
    $errTempId = 'e'.mt_rand(0,9999999999999);
    $onClick = "e=document.getElementById('".$errTempId."');if(e.style.display=='none'){e.style.display='';}else{e.style.display='none';}";
    echo '<strong style="color:#006699"><acronym style="cursor:pointer;" title="'.$info.'" onClick="'.$onClick.'"><span style="font-size:11px; font-weight:normal;">'.$infoS.' debug:</span></acronym></strong><span id="'.$errTempId.'">';
    if( is_object($data) === true or is_array($data) === true ) {
        echo '<pre>';
        print_r($data);
        echo '</pre><br />';
    } else if( is_null($data) ) {
        echo '<i>NULL</i><br />';
    } else {
        echo $data.'<br />';
    }
    echo '</span>';
}

function arrayMerge( $a, $b ) {
    foreach( $b as $k => $v ) {
        $a[$k] = $v;
    }
    return $a;
}

error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE);
error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE & ~E_WARNING);

// Setup autoloading
require 'init_autoloader.php';

// Run the application!
Zend\Mvc\Application::init(require 'config/application.config.php')->run();

htaccess文件(以防我需要修改此处的任何内容)

RewriteEngine On
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The 
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to 
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size 
# fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
# The following rule blocks botnets scripts
RewriteCond %{HTTP_USER_AGENT} libwww-perl.* 
RewriteRule .* – [F,L]
# The following rule maps IP address with domain name
RewriteCond %{HTTP_HOST} ^***\.**\.***\.**
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

1 个答案:

答案 0 :(得分:0)

通常,public / dir是zend应用程序中唯一的公共可访问目录,并用作域的文档根目录。 因此,如果您希望自己的博客位于domain.com/blog/下,则必须将其发布到public / blog /

您无需修改​​zend应用程序的任何文件。