我从这里开始在WP中使用Yii: http://www.yiiframework.com/doc/guide/1.1/en/extension.integration#using-yii-in-3rd-party-systems
我收到了这个错误:
Internal Server Error
include(Translation_Entry.php): failed to open stream: No such file or directory
An internal error occurred while the Web server was processing your request. Please contact the webmaster to report this problem.
Thank you.
2015-02-22 12:08:01
我找到它(Have wordpress as a module or extension in Yii)并按照第一个答案。现在我的index.php看起来像这样:
define('WP_USE_THEMES', true);
///** Load Yii Framework */
$yii=dirname(__FILE__).'/Yii/framework/yii.php';
$config=dirname(__FILE__).'/Yii/protected/config/main.php';
spl_autoload_unregister(array('YiiBase','autoload'));
$wp=dirname(__FILE__).'/wp-load.php';
require_once($wp);
spl_autoload_register(array('YiiBase','autoload'));
require_once($yii);
Yii::createWebApplication($config);
/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
现在我收到此错误消息:
**Fatal error**: Call to a member function add_query_var() on string in C:\xampp\htdocs\wpyii_01\wp-includes\taxonomy.php on line 355
我不知道它有什么问题。
如果有人发现此错误并解决了,请帮助我。
更新:我将代码的有趣部分更改为:
spl_autoload_unregister(array('YiiBase','autoload'));
require_once(dirname(__FILE__) . '/wp-load.php' );
require_once(dirname(__FILE__) .'/Yii/framework/yii.php');
spl_autoload_register(array('YiiBase','autoload'));
Yii::createWebApplication(dirname(__FILE__) . '/Yii/protected/config/main.php');
现在这没有任何错误。
我如何获得解决方案: 我改变了:
$wp=dirname(__FILE__).'/wp-load.php';
require_once($wp);
到
require_once(dirname(__FILE__) . '/wp-load.php' );
这里我收到了一条新的错误信息:
Fatal error: Uncaught exception 'LogicException' with message 'Passed array does not specify an existing static method (class 'YiiBase' not found)' in C:\xampp\htdocs\wpyii_01\index.php:19 Stack trace: #0 C:\xampp\htdocs\wpyii_01\index.php(19): spl_autoload_register(Array) #1 {main} thrown in C:\xampp\htdocs\wpyii_01\index.php on line 19
之后我把框架需要代码放到spl_autoload块中,现在它运行得很好。
我正在测试。在测试插件中,此返回值运行良好:
return $content . CHtml::tag("h1",array(),"Hello Worlddd!","/h1");
下一步是尝试Yii数据库连接。
谢谢你,KOovi