Yii Framework Forum: Running Several Different Instances Of Yii Application? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Running Several Different Instances Of Yii Application? Rate Topic: -----

#1 User is offline   Victor Porton 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 21-January 13

Posted 23 July 2013 - 02:19 PM

I want to run several different instances of a Yii application with different options (in fact every instance differs from other by the value of MySQL login and password, so effectively using different databases).

If we have only two instances it can be done by creating two.php with a copy of index.php and specify the info for alternate config there.

But what if I want to run more than two (an unlimited number) of instances of my application? How could this be done?

This could be done adding ?xxx=yyy to the URL, but when clicking a link or submitting a form, Yii would "forget" that ?xxx=yyy specifying that it is for an alternate app instance.
0

#2 User is offline   KonApaz 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,317
  • Joined: 21-February 11
  • Location:Greece

Posted 23 July 2013 - 03:54 PM

create a multiomain.php in protected/config with this code:

$myid = $_GET['xxx'];

return CMap::mergeArray(
	require(dirname(__FILE__).'/main.php'),
	array(
'components'=>array(
            'db'=>array(
			'connectionString' => 'mysql:host=localhost;dbname=mydatabase_'. $myid ,
			'emulatePrepare' => true,
			'username' => 'userdatabase_'. $myid,
			'password' => 'password_'. $myid ,
			'charset' => 'utf8',
		),
            ),
         ));


but be careful with $myid!, it should be purified from malicius characters
Yii is the best php framework in the world!
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
0

#3 User is offline   Victor Porton 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 21-January 13

Posted 24 July 2013 - 05:47 AM

The trouble is to preserve $myid when one clicks links or submit forms with ?xxx=

It seems that your code does not do that.

View PostKonApaz, on 23 July 2013 - 03:54 PM, said:

create a multiomain.php in protected/config with this code:

$myid = $_GET['xxx'];

return CMap::mergeArray(
	require(dirname(__FILE__).'/main.php'),
	array(
'components'=>array(
            'db'=>array(
			'connectionString' => 'mysql:host=localhost;dbname=mydatabase_'. $myid ,
			'emulatePrepare' => true,
			'username' => 'userdatabase_'. $myid,
			'password' => 'password_'. $myid ,
			'charset' => 'utf8',
		),
            ),
         ));


but be careful with $myid!, it should be purified from malicius characters

0

#4 User is offline   KonApaz 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,317
  • Joined: 21-February 11
  • Location:Greece

Posted 24 July 2013 - 08:56 AM

View PostVictor Porton, on 24 July 2013 - 05:47 AM, said:

The trouble is to preserve $myid when one clicks links or submit forms with ?xxx=

It seems that your code does not do that.


you could set it in session

Yii::app()->user->setState('myid', $myid);
//or
Yii::app()->session['myid']= $myid;

Yii is the best php framework in the world!
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users