having followed the way to create a webapp in the Yii book, The app complains about the "autoload"

Below is the error msg reported by httpd:

[Sat Jul 14 12:38:35.506203 2012] [:error] [pid 2300:tid 139876527757056] [client 192.168.0.111:51405] PHP Fatal error: Uncaught exception ‘LogicException’ with message ‘Passed array does not specify an existing static method (class ‘YiiBase’ does not have a method ‘autoload’)’ in /usr/local/apache2/htdocs/yii-1.1.8.r3324/framework/YiiBase.php:849\nStack trace:\n#0 /usr/local/apache2/htdocs/yii-1.1.8.r3324/framework/YiiBase.php(849): spl_autoload_register(Array)\n#1 /usr/local/apache2/htdocs/yii-1.1.8.r3324/framework/yii.php(14): require(’/usr/local/apac…’)\n#2 /usr/local/apache2/htdocs/practise/demo/index.php(12): require_once(’/usr/local/apac…’)\n#3 {main}\n thrown in /usr/local/apache2/htdocs/yii-1.1.8.r3324/framework/YiiBase.php on line 849, referer:

My server environment:

Centos 6.2 X64 minimum with application developement yum package

Apache 2.4 , PHP 5.4, both manaual installation. And the Apache and php are working well as I have checked with simple php script.

Also, I have checked the YiiBass.php , it does have the public static autoload function.

the directory layout:

/usr/local/apache2/htdocs/yii-frameworkroot

/usr/local/apache2/htdoc/practise/demo

practise is virtual server root hosted by Apache

Anyone have an idea about this ? thanks so much

Do you have a default installation of a yii web application?

Do you have


spl_autoload_register(array('YiiBase','autoload'));

In you YiiBase at line 849?

I thought maybe it’s something php version dependent, but seems this function wasn’t updated since 5.3 version.

While googling the error you’ve got I found it was caused by usage with namespaces - not sure it can be your problem, just looking for ideas :)

And what is your index.php file code?

Yes, yugene. It’s the well-known demo application I created for testing. The whole process was like below:


[root@mirror practise]# /usr/local/php5/bin/php /usr/local/apache2/htdocs/yii-1.1.8.r3324/framework/yiic webapp demo

Create a Web application under '/usr/local/apache2/htdocs/practise/demo'? [Yes|No] Y

      mkdir /usr/local/apache2/htdocs/practise/demo

   generate index-test.php

      mkdir /usr/local/apache2/htdocs/practise/demo/images

   generate index.php

      mkdir /usr/local/apache2/htdocs/practise/demo/assets

      mkdir /usr/local/apache2/htdocs/practise/demo/css

   generate css/main.css

   generate css/bg.gif

   generate css/screen.css

   generate css/ie.css

   generate css/print.css

   generate css/form.css

      mkdir /usr/local/apache2/htdocs/practise/demo/protected

      mkdir /usr/local/apache2/htdocs/practise/demo/protected/models

   generate protected/models/LoginForm.php

   generate protected/models/ContactForm.php

      mkdir /usr/local/apache2/htdocs/practise/demo/protected/migrations

      mkdir /usr/local/apache2/htdocs/practise/demo/protected/commands

      mkdir /usr/local/apache2/htdocs/practise/demo/protected/commands/shell

      mkdir /usr/local/apache2/htdocs/practise/demo/protected/data

   generate protected/data/schema.sqlite.sql

   generate protected/data/schema.mysql.sql

   generate protected/data/testdrive.db

   generate protected/yiic

      mkdir /usr/local/apache2/htdocs/practise/demo/protected/extensions

      mkdir /usr/local/apache2/htdocs/practise/demo/protected/config

   generate protected/config/main.php

   generate protected/config/console.php

   generate protected/config/test.php

      mkdir /usr/local/apache2/htdocs/practise/demo/protected/tests

      mkdir /usr/local/apache2/htdocs/practise/demo/protected/tests/unit

      mkdir /usr/local/apache2/htdocs/practise/demo/protected/tests/fixtures

   generate protected/tests/WebTestCase.php

   generate protected/tests/bootstrap.php

   generate protected/tests/phpunit.xml

      mkdir /usr/local/apache2/htdocs/practise/demo/protected/tests/functional

   generate protected/tests/functional/SiteTest.php

      mkdir /usr/local/apache2/htdocs/practise/demo/protected/tests/report

      mkdir /usr/local/apache2/htdocs/practise/demo/protected/runtime

      mkdir /usr/local/apache2/htdocs/practise/demo/protected/views

      mkdir /usr/local/apache2/htdocs/practise/demo/protected/views/site

   generate protected/views/site/login.php

   generate protected/views/site/index.php

      mkdir /usr/local/apache2/htdocs/practise/demo/protected/views/site/pages

   generate protected/views/site/pages/about.php

   generate protected/views/site/contact.php

   generate protected/views/site/error.php

      mkdir /usr/local/apache2/htdocs/practise/demo/protected/views/layouts

   generate protected/views/layouts/main.php

   generate protected/views/layouts/column1.php

   generate protected/views/layouts/column2.php

      mkdir /usr/local/apache2/htdocs/practise/demo/protected/messages

   generate protected/yiic.php

   generate protected/.htaccess

      mkdir /usr/local/apache2/htdocs/practise/demo/protected/components

   generate protected/components/UserIdentity.php

   generate protected/components/Controller.php

      mkdir /usr/local/apache2/htdocs/practise/demo/protected/controllers

   generate protected/controllers/SiteController.php

   generate protected/yiic.bat

      mkdir /usr/local/apache2/htdocs/practise/demo/themes

      mkdir /usr/local/apache2/htdocs/practise/demo/themes/classic

      mkdir /usr/local/apache2/htdocs/practise/demo/themes/classic/views

      mkdir /usr/local/apache2/htdocs/practise/demo/themes/classic/views/site

      mkdir /usr/local/apache2/htdocs/practise/demo/themes/classic/views/system

   generate themes/classic/views/.htaccess

      mkdir /usr/local/apache2/htdocs/practise/demo/themes/classic/views/layouts


Your application has been created successfully under /usr/local/apache2/htdocs/practise/demo.

And the index.php looks like below


<?php


// change the following paths if necessary

$yii=dirname(__FILE__).'/../../yii-1.1.8.r3324/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);

// specify how many levels of call stack should be shown in each log message

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


require_once($yii);

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



Since I’ve not started to develope applications, Namespace issue seems unlikely the cause. And, Line 849 does have codes you mentioned above. Anyway, I’m deciding downgrading PHP 5.4.3 to PHP 5.3.14. Let’see if the problem is still there

Thanks, yugene

hey, yugene, it looks like the issue is caused by PHP version 5.4.3. Although the root cause is still unknown ( I guess it has something to do with parser), the demo app is working well under the combination of Apache 2.4 and PHP 5.3.14.

Hope this thread helps those setting up yii framework in a server environment such as CentOs 6.2 X86-64, Apache 2.4

Hm, interesting to know your results, though I don’t think it’s an expected behavior and it would be useful to know the cause.

I had exactly same problem.

Solution was to disable APC for current server.

I had the same problem, And it started as i installed APC on my server, since I needed APC methods removing

it from the server was not an option, So instead i disabled the php cache part, and yet the methods were available.

In order to disable the php caching all you have to do is adding the following code to your php.ini, (or changing it if it exists, It may also be on apc.ini for linux base servers)


[apc]

apc.enabled = 0

Here you can see the full apc runtime configuration