How to using Yii Framweork in WordPress?

I started from here to use Yii in WP:
http://www.yiiframework.com/doc/guide/1.1/en/extension.integration#using-yii-in-3rd-party-systems

I got this error:

Read More
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

I find it (Have wordpress as a module or extension in Yii) and follow the first answer. Now my index.php is look like this:

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' );

Now I got this error message:

**Fatal error**: Call to a member function add_query_var() on string in C:xampphtdocswpyii_01wp-includestaxonomy.php on line 355

And I can not know what is the problem with it.

If somebody find this error and solved it please help me.

Update: I changed the interesting part of the code to:

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');

And now this is not has any error.

How I get the solution:
1. I changed:

$wp=dirname(__FILE__).'/wp-load.php';
require_once($wp);

to

require_once(dirname(__FILE__) . '/wp-load.php' );

Here i got a new wrror message:

Fatal error: Uncaught exception 'LogicException' with message 'Passed array does not specify an existing static method (class 'YiiBase' not found)' in C:xampphtdocswpyii_01index.php:19 Stack trace: #0 C:xampphtdocswpyii_01index.php(19): spl_autoload_register(Array) #1 {main} thrown in C:xampphtdocswpyii_01index.php on line 19

After it i put the framework require code into the spl_autoload block, and now it is working very well.

I am testing. In a test plugin this return value is worked well:

return $content . CHtml::tag("h1",array(),"Hello Worlddd!","/h1"); 

Next step is try to Yii database connections.

Thank you, KOovi

Related posts

Leave a Reply