Yii import or include

15,404

Try to do Yii::import('ext.payu.payU', true) because default one-parameter Yii::import() function call means:

hey, just add this path to the known aliases list and do not require() it now

and you have to do new payU() for this to work.

Share:
15,404
abuduba
Author by

abuduba

Updated on June 14, 2022

Comments

  • abuduba
    abuduba almost 2 years

    I encountered a problem about importing php files.

    Why this works:

    include( Yii::getPathOfAlias( 'ext.payu.payU').'.php' );
    

    but that don't:

    Yii::import( 'ext.payu.payU');
    

    ?

    file payU.php:

    include_once( dirname(__FILE__) . "/sdk/openpayu.php"); //this is a valid path
    class payU{ }
    
    • Waihon Yew
      Waihon Yew over 11 years
      What does "not work" mean? Please provide some code and any relevant setPathOfAlias calls (if there are such).