PHP Error - new webapp

Hello,

I have the problem, that I’ve created a webapp localy on my machine and uploaded on my webserver.

I’ve made some little changes in the /protected/config/main.php




dirname(__FILE__).DIRECTORY_SEPARATOR.'..',

	'name'=>'pocra',


	// preloading 'log' component

	'preload'=>array('log'),


	// autoloading model and component classes

	'import'=>array(

		'application.models.*',

		'application.components.*',

	),


	// application components

	'components'=>array(

		'user'=>array(

			// enable cookie-based authentication

			'allowAutoLogin'=>true,

		),

		// enable URLs in path-format

		/*'urlManager'=>array(

			'urlFormat'=>'path',

			'rules'=>array(

				'/'=>'<controller>/view',

				'//'=>'<controller>/<action>',

				'/'=>'<controller>/<action>',

			),

		),

        */

		/*

		'db'=>array(

			'connectionString' => 'sqlite:protected/data/testdrive.db',

		),

		*/

		// MySQL database

		'db'=>array(

			'connectionString' => 'mysql:host=localhost;dbname=XXXXXX',

			'emulatePrepare' => true,

			'username' => 'XXX',

			'password' => 'XXX',

			'charset' => 'utf8',

		),

		'errorHandler'=>array(

			// use 'site/error' action to display errors

            'errorAction'=>'site/error',

        ),

		'log'=>array(

			'class'=>'CLogRouter',

			'routes'=>array(

				array(

					'class'=>'CFileLogRoute',

					'levels'=>'error, warning',

				),

				// uncomment the following to show log messages on web pages

				/*

				array(

					'class'=>'CWebLogRoute',

				),

				*/

			),

		),

	),


	// application-level parameters that can be accessed

	// using Yii::app()->params['paramName']

	'params'=>array(

		// this is used in contact page

		'adminEmail'=>'XXXXXX',

	),

);



and in the index.php




<?php


// change the following paths if necessary

$yii=dirname(__FILE__).'/framework/yii.php';

$config=dirname(__FILE__).'/protected/config/main.php';


// remove the following lines when in production mode

defined('YII_DEBUG') or define('YII_DEBUG',true);

defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);


require_once($yii);

Yii::createWebApplication($config)->run();

?>



and I receive the following error:

The requirement says, that’s all right (except SQLite and APC Extension)

What is the stack trace?




#0 /yii/pocra/framework/YiiBase.php(338): autoload()

#1 unknown(0): autoload()

#2 /yii/pocra/protected/controllers/SiteController.php(3): spl_autoload_call()

#3 /yii/pocra/framework/web/CWebApplication.php(388): require()

#4 /yii/pocra/framework/web/CWebApplication.php(314): CWebApplication->createController()

#5 /yii/pocra/framework/web/CWebApplication.php(120): CWebApplication->runController()

#6 /yii/pocra/framework/base/CApplication.php(135): CWebApplication->processRequest()

#7 /yii/pocra/index.php(12): CWebApplication->run()



Do you have Controller.php in protected/components?

Yibb - the file is on the server with the following content:




<?php

/**

 * Controller is the customized base controller class.

 * All controller classes for this application should extend from this base class.

 */

class Controller extends CController

{

	/**

	 * @var string the default layout for the controller view. Defaults to 'application.views.layouts.column1',

	 * meaning using a single column layout. See 'protected/views/layouts/column1.php'.

	 */

	public $layout='application.views.layouts.column1';

	/**

	 * @var array context menu items. This property will be assigned to {@link CMenu::items}.

	 */

	public $menu=array();

	/**

	 * @var array the breadcrumbs of the current page. The value of this property will

	 * be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}

	 * for more details on how to specify this property.

	 */

	public $breadcrumbs=array();

}



Did you check upper/lowercase filename? It needs to be exactly "Controller.php" or the file will not be found. Linux filesystems are case sensitive.

I’ve checked it…that’s okay

Later I’ll try to create a new webapp with other foldernames

Can you change this line in your index.php


Yii::createWebApplication($config)->run();



to


Yii::createWebApplication($config);

echo get_include_path();



And check the output? Your Controller.php must be in one of the provided paths (’:’ separated).




dirname(__FILE__).DIRECTORY_SEPARATOR.'..',

	'name'=>'pocra',

 

	// preloading 'log' component

	'preload'=>array('log'),

 

	// autoloading model and component classes

	'import'=>array(

		'application.models.*',

		'application.components.*',

	),

 

	// application components

	'components'=>array(

		'user'=>array(

			// enable cookie-based authentication

			'allowAutoLogin'=>true,

		),

		// enable URLs in path-format

		/*'urlManager'=>array(

			'urlFormat'=>'path',

			'rules'=>array(

				'/'=>'<controller>/view',

				'//'=>'<controller>/<action>',

				'/'=>'<controller>/<action>',

			),

		),

        */

		/*

		'db'=>array(

			'connectionString' => 'sqlite:protected/data/testdrive.db',

		),

		*/

		// MySQL database

		'db'=>array(

			'connectionString' => 'mysql:host=localhost;dbname=XXX',

			'emulatePrepare' => true,

			'username' => 'XXX',

			'password' => 'XXX',

			'charset' => 'utf8',

		),

		'errorHandler'=>array(

			// use 'site/error' action to display errors

            'errorAction'=>'site/error',

        ),

		'log'=>array(

			'class'=>'CLogRouter',

			'routes'=>array(

				array(

					'class'=>'CFileLogRoute',

					'levels'=>'error, warning',

				),

				// uncomment the following to show log messages on web pages

				/*

				array(

					'class'=>'CWebLogRoute',

				),

				*/

			),

		),

	),

 

	// application-level parameters that can be accessed

	// using Yii::app()->params['paramName']

	'params'=>array(

		// this is used in contact page

		'adminEmail'=>'XXX',

	),

);.:/usr/share/php:/usr/share/pear



What is this? Did you echo the $config too?

If that’s the output of your include path on the bottom: It’s missing the directories you imported (they will usually be added to PHP’s include_path). That could mean: Your PHP setup doesn’t allow to change the include_path.

You should check with phpinfo() in a separate script. One canidate could be open_basedir restriction.

Yeah, that’s the output…

That’s the include_path: :/usr/share/php:/usr/share/pear

That’s the open_basedir: /home/12154

Is there a workaround for this issue?

Parallel I’ll contact my provider…

You can put your yii installation somewhere under /home/12154. Make sure, the framework directory is not accessible from the web (.htaccess with deny from all).

I’ve putted the framework to /home/12154/yii and changed the path to yii in the index.php

The output is exactly the same! :(

Hmm. That’s strange. Maybe you can debug a little.

Include path is set, when you create a CApplication with ‘import’ in it’s config. This is done in YiiBase::config() (around line 273).

For a test you could save a copy of framework/YiiBase.php and add some print_r(…) here and there to see, what’s going on.

Addition:

include_path must contain the path to your protected/components directory.