Hello, i have run into problem, i have develpoed website on my local server, everything looked fine, but i have uploaded it to hosting server, and got error:
include(ModelClass.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory
public static function autoload($className)
// use include so that the error PHP file may appear
include($className.'.php'); // <- this line causes problem
I do not understand how include(‘ModelClass.php’); can work on framework directory on my local server… if so, why hosting server can’t?
It could be that your hosting server doesn't allow setting PHP include path.
The reason that you can use "ModelClass" without including it explicitly is because Yii uses autoload to automatically include ModelClass.php (without full path) and it relies on PHP include path to find the correct file. In your app config, you have imported "application.models.*", which actually adds the models path to PHP include path.
What can I do if my hosting server doesn’t support include_path, or doesnt allow to change it. I haven’t permision to access php.ini, and i have tryied to set it in .htaccess file (default values, to test), but this caused me 500 Internal Server Error.
php_value include_path ".:\usr\local\php5\lib\php"
Explicitly include the model file where it is used. You may use the following syntax:
Yii::import hasn't helped too, so now i am using require_once… now it is working…
Is the class file name the same as the class (case-sensitive on *nix)?