rohit
(Rohit N Sarpotdar)
December 14, 2009, 2:07pm
1
Hi,
I’m not sure, if I’m the only one who faces this problem of disabling get_include_path and set_include_path on shared hosting service.
I have tried to implement the alternative for it. But still when I created modules, it again fell apart…
I would like to see some support for shared hosting where these functions are disabled.
There might be some advantages of using it, but if it is possible to have some alternative please tell me.
Regards.
rohit
(Rohit N Sarpotdar)
June 11, 2011, 5:14am
2
I found a patch to fix the issue. Following is the modified version of autoload function.
I just added a check if set_include_path is disabled and only then do something.
Remove exception thrown in include function for set_include_path.
public static function autoload($className)
{
// use include so that the error PHP file may appear
if(isset(self::$_coreClasses[$className]))
include(YII_PATH.self::$_coreClasses[$className]);
else if(isset(self::$classMap[$className]))
include(self::$classMap[$className]);
else
{
if(strpos($className,'\\')===false)
{
// set_include_path is disabled on shared hosting
if(set_include_path(get_include_path())===false)
{
foreach(self::$_includePaths as $dir)
{
$fullClassName = $dir.DIRECTORY_SEPARATOR.$className.'.php';
if(is_file($fullClassName))
break;
}
include($fullClassName);
unset($fullClassName);
}
else
{
include($className.'.php');
}
}
else // class name with namespace in PHP 5.3
{
$namespace=str_replace('\\','.',ltrim($className,'\\'));
if(($path=self::getPathOfAlias($namespace))!==false)
include($path.'.php');
else
return false;
}
return class_exists($className,false) || interface_exists($className,false);
}
return true;
}
rohit
(Rohit N Sarpotdar)
June 11, 2011, 5:19am
3
In above post I added 4 lines of code
if(set_include_path(get_include_path())===false)
{
foreach(self::$_includePaths as $dir)
{
$fullClassName = $dir.DIRECTORY_SEPARATOR.$className.'.php';
if(is_file($fullClassName))
break;
}
include($fullClassName);
unset($fullClassName);
}
Also, will need to remove exception thrown on the check of set_include_path, in include function.
Quang can you please check if this can be included in main stream. I know you don’t support shared hosting.
But for guy like me, who wants to do experiments, and also wants to use Yii, shared hosting is the best option!
Can you please consider once???
Thanks in advance.
alain091
(Alain091)
June 12, 2011, 8:53am
4
I think you also must change the import method
jacmoe
(Jacob Moena)
June 12, 2011, 12:08pm
5
Could you open a ticket at the issue tracker at Google.code?
That would make it a lot easier for the Yii team to consider it.
rohit
(Rohit N Sarpotdar)
June 13, 2011, 8:12pm
6
There was previously issue filed. but this is how it was closed…
issue 1218
I just think, I have the cleaner solution.
@ alain091 yes , i will need to disable the thrown exception. That’s all. I figured, $_includePaths varialbe gets all the paths correctly. Thus, just have to search for which path to be attached with current class. That’s all I have done.
I have created new issue 2532
I hope they consider. It will make life easier for those who still like to use yii on shared hostings