0

We have created numerous web pages in 'plain' PHP(which also involves a lot of javascript and ajax code) which need to be "Integrated" into a website built in YII framework(maintained by someone else).

These plain PHP pages are working fine(bug free) currently when used separately.

Kindly suggest/instruct us about the simplest/smartest procedure of integrating our webpages into the website(developed in YII) which requires minimal possible YII development knowledge since none of us are very experienced in it.

Thanks all, Prateek A.

1
  • Is this Yii1.x or Yii2 ? Commented Jun 21, 2014 at 12:27

1 Answer 1

1

Create a Controller for your integration call it say Integration Controller

Class IntegrationController extends CController { 
  public actionPage1(){
     $this->render('page1');
  }
}

For each page create an action and move your pages into the corresponding views/integration folder as page1.php, page2.php and so on.

You can access page1 with <app_root>index.php?r=Integration/page1 and page2 with <app_root>index.php?r=Integration/page2 so on and so forth. If you want different routing create more controllers and actions accordingly.

Ideally you should move you Business Logic away from view files such as page1.php into the controller and models. But this will get you quickly integrated even though it is not best MVC practice.

In addition to this you will have to reroute all your ajax requests within the code accordingly. For example your old request when to a page called "myoldpage.php",

$.get({
   url:"myoldpage.php"
 ....

you can use Yii createUrl class and create the new url in the url attribute like this

 $.get({
   url: <?php echo Yii::app()->createUrl('Integration/newPage'); ?>

Note: This controller structure works in Yii1.x, Yii2 will be slightly different

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.