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

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

having followed the way to create a webapp in the Yii book, The app complains about the "autoload" when I try to access the index.php page, the browser gives a blankpage Rate Topic: -----

#1 User is offline   ca1044 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 13-July 12

Posted 14 July 2012 - 12:09 AM

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
0

#2 User is offline   yugene 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 413
  • Joined: 08-August 09
  • Location:Ukraine

Posted 15 July 2012 - 03:15 AM

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?
0

#3 User is offline   ca1044 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 13-July 12

Posted 15 July 2012 - 07:00 AM

View Postyugene, on 15 July 2012 - 03:15 AM, said:

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
0

#4 User is offline   ca1044 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 13-July 12

Posted 15 July 2012 - 10:09 AM

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
0

#5 User is offline   yugene 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 413
  • Joined: 08-August 09
  • Location:Ukraine

Posted 16 July 2012 - 03:40 AM

View Postca1044, on 15 July 2012 - 10:09 AM, said:

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.

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.
0

#6 User is offline   Oleg L 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 08-June 13

Posted 08 June 2013 - 06:31 AM

I had exactly same problem.

Solution was to disable APC for current server.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users