문제

I am trying to import facebook SDK but directory name is "php-sdk-3.2.2" and when try to import -"Yii::import('ext.yii-facebook-opengraph.php-sdk-3.2.2');" the SDK version is breaking the importation.

도움이 되었습니까?

해결책

As tinyByte mentions you will have to change your file/directory name. There is no simple way around it.

Yii Import function calls getPathOfAlias which is defined in Yii::base as below

public static function getPathOfAlias($alias)
{
    if(isset(self::$_aliases[$alias]))
        return self::$_aliases[$alias];
    elseif(($pos=strpos($alias,'.'))!==false)
    {
        $rootAlias=substr($alias,0,$pos);
        if(isset(self::$_aliases[$rootAlias]))
            return self::$_aliases[$alias]=rtrim(self::$_aliases[$rootAlias].DIRECTORY_SEPARATOR.str_replace('.',DIRECTORY_SEPARATOR,substr($alias,$pos+1)),'*'.DIRECTORY_SEPARATOR);
        elseif(self::$_app instanceof CWebApplication)
        {
            if(self::$_app->findModule($rootAlias)!==null)
                return self::getPathOfAlias($alias);
        }
    }
    return false;
}

As you can see it uses strpos to parse the string, unless you modify the core( or extend Yii::Base) to write some escaping logic to parse directory names with '.' you will not be able to use the directory names with "." in them.

If you cannot change the directory name for some reason simply create a symbolic link to it without the dots

ln -s /path/to/extensions/yii-facebook-opengraph/php-sdk-3.2.2/ /path/to/extensions/yii-facebook-opengraph/php-sdk-3-2-2/

and reference in Yii as Yii::import('ext.yii-facebook-opengraph.php-sdk-3-2-2'

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top