How to get Gii working on Limesurvey installation

More
5 months 6 days ago #154920 by allanzmn
allanzmn created the topic: How to get Gii working on Limesurvey installation
Hi everyone.

I´m new to Yii and Limesurvey plus the last version I used of PHP was 4.6. I´m sorry if this is a stupid question. I´ll make sure to search as much as I can before posting any doubts.

I´m recently back to PHP and I was assigned to develop a plugin to integrate limesurvey with the companys CRM software. I would like to use Gii to generate some code to me as It would save me time and would help me with my learning curve. I checked Gii docs ( www.yiiframework.com/doc-2.0/guide-start-gii.html ) but I couldn´t make it work on the Limesurvey installation. Could anyone assist?

Thanks.

Please Log in to join the conversation.

More
5 months 6 days ago #154922 by allanzmn
allanzmn replied the topic: How to get Gii working on Limesurvey installation
Found this on config/internal.php:

'modules'=>array(
'gii'=>array(
'class'=>'system.gii.GiiModule',
// 'password'=>'toto',
// 'ipFilters'=>array(...a list of IPs...),
// 'newFileMode'=>0666,
// 'newDirMode'=>0777,
),
),

I suppose this is where it sould be activated. I tried to uncomment but when I try accessing http://mylime/index.php?r=gii it takes me to the front page with the public surveys list.

Please Log in to join the conversation.

More
5 months 6 days ago - 5 months 6 days ago #154950 by allanzmn
allanzmn replied the topic: How to get Gii working on Limesurvey installation
Got it to work accessing by:

http://mylime/gii

No i´m trying to point Gii to another MySql DB that I want to build the ActiveRecords. I created another db component in the config.php file as bellow:
'db_exata' => array(
class' => 'yii\db\Connection',
'connectionString' => 'mysql:host=localhost;port=3306;dbname=test;',
'username' => 'user',
'password' => 'pass',
),

But when fill Gii model form with the proper information and try to preview I get:

Error 500
Alias "yii.db" is invalid. Make sure it points to an existing directory or file.

Sorry... Just pointed to CDbConnection class and it worked fine.

Last Edit: 5 months 6 days ago by allanzmn. Reason: Solved

Please Log in to join the conversation.

More
5 months 5 days ago - 5 months 5 days ago #154956 by LouisGac
LouisGac replied the topic: How to get Gii working on Limesurvey installation
Extending Gii to make possible to use it to generate base code for plugins/questions templates etc is one of my long term goal (I still have to convince the rest of the team, and we already have a lot of things to do right now).

I used it to generate the Home Page settings, so I'd strongly suggest you have a look into the commits related to that page. You'll see that LS controllers/actions/views system is not 100% in the Yii style, and you must modify few files after you used Gii. See this commit, and adminController + mother class of homepagesettings (Survey_Common_Action) :
github.com/LimeSurvey/LimeSurvey/commit/...cbaebaf24298d2c45fa9



Concerning the external DB:
www.yiiframework.com/doc/guide/1.1/en/database.dao


In Yii1, name space feature is not really integrated. So you must use the class "CDbConnection", and not the name space 'yii\db\Connection'

        'dbExata'=>array(
            'class'=>'CDbConnection',
            'connectionString'=>'mysql:host=localhost;dbname=testdb',
            'username'=>'root',
            'password'=>'password',
            'emulatePrepare'=>true,  // needed by some MySQL installations
        ),

Your code is valid for Yii2, which is using modern PHP syntax. But LimeSurvey uses Yii1, not Yii2.
Last Edit: 5 months 5 days ago by LouisGac.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now