Include Index.php To Call Yii Framework, Possible?

My old website is calling index.php, and then according to the parameter - "link" to load corresponding page to display the site.


<?php

switch ($_GET['link'])

{

  case 'shopping': include 'action/shopping.php'; break;

  ...

  ...

  case 'pay': include 'action/pay.php'; break;

  ...

  ...

  default: include 'action/home.php';

}

die();



Now I want to revamp my old website by using Yii Framework. :D

However, I don’t have so much time to all the page, and my old version also need to create some events for the visitors etc.

That why I am thinking to write my index.php into this…




switch ($_GET['link'])

{

  case 'shopping': include 'action/shopping.php'; break;

  ...

  ...

  case 'pay': include 'action/pay.php'; break;

  ...

  ...

  case 'new_event':

    $_GET['r']='new_event/index';

    include '../yii_htdocs/index.php';

    die();

  return;

  default: include 'action/home.php';

}

die();



However, there are a lot of errors if I calling Yii by this way. :(

I don’t want to use redirect… because I want to keep index.php

How to solve this issue?

Thanks!




switch ($_GET['link'])

{

  case 'shopping': include 'action/shopping.php'; break;

  ...

  ...

  case 'pay': include 'action/pay.php'; break;

  ...

  ...

  case 'new_event':

                $yii=dirname(__FILE__).'/../yii_htdocsyii/framework/yii.php';

$config=dirname(__FILE__).'yii_htdocs/protected/config/main.php';


// remove the following lines when in production mode

defined('YII_DEBUG') or define('YII_DEBUG',true);

// specify how many levels of call stack should be shown in each log message

defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);


require_once($yii);

Yii::createWebApplication($config)->run();




  default: include 'action/home.php';

}

die();



Correct the both $config,$yii variable path and try this.

[/quote]

You need to take some time to understand Model View Controller and how it’s implemented in Yii:

http://www.yiiframework.com/doc/guide/1.1/en/basics.mvc

What you were doing in index.php without Yii, is now handled by the application by means of controllers, actions in those controllers, views and models.