cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

Strange error after migration to Phalcon 3.0.0

Open vekyapps opened this issue 10 years ago • 170 comments

Hello,

yesterday, I migrated my project to Phalcon 3.0 (from 2.1 version). And everything worked fine, except now I got very "randomly" this error:

Fatal error: Uncaught Error: Access to undeclared static property: Phalcon\Di::$_default in C:\xampp-php7-0\htdocs\aplikacija\app\config\services.php:25 Stack trace:
#0 [internal function]: Phalcon\Di->__construct()
#1 C:\xampp-php7-0\htdocs\aplikacija\app\config\services.php(25): Phalcon\Di\FactoryDefault->__construct()
#2 C:\xampp-php7-0\htdocs\aplikacija\public\index.php(25): include('C:\\xampp-php7-0...')
#3 {main}

Next Error: Access to undeclared static property: Phalcon\Di::$_default in C:\xampp-php7-0\htdocs\aplikacija\app\config\services.php:25 Stack trace:
#0 [internal function]: Phalcon\Di->__construct()
#1 C:\xampp-php7-0\htdocs\aplikacija\app\config\services.php(25): Phalcon\Di\FactoryDefault->__construct()
#2 C:\xampp-php7-0\htdocs\aplikacija\public\index.php(25): include('C:\\xampp-php7-0...')
#3 {main} thrown in C:\xampp-php7-0\htdocs\aplikacija\app\config\services.php on line 25

On line 25 in my services.php file is where I create instance of DI factory class:

$di = new FactoryDefault();   ( this is line 25 - error line!)
$di->setShared('config', function () use ($config) {
    return $config;
});

I work on Windows, Xampp v3.2.2 with PHP 7.0.8 and Phalcon 3.0.

Can you help me with this?

Thanks in advance!

vekyapps avatar Jul 30 '16 22:07 vekyapps

My only guess it's beacause of windows perhaps ? Works on vagrant/ubuntu 14.04 without any problem.

Jurigag avatar Jul 31 '16 08:07 Jurigag

What is $config?

Studentsov avatar Jul 31 '16 11:07 Studentsov

Hello. I have the same error

Fatal error: Uncaught Error: Access to undeclared static property: Phalcon\Di::$_default in C:\xamppwin\htdocs\phalcon\app\config\services.php:6 Stack trace:
#0 [internal function]: Phalcon\Di->__construct()
#1 C:\xamppwin\htdocs\phalcon\app\config\services.php(6): Phalcon\Di\FactoryDefault->__construct()
#2 C:\xamppwin\htdocs\phalcon\public\index.php(21): require('C:\\xamppwin\\htd...')
#3 {main}

Next Error: Access to undeclared static property: Phalcon\Di::$_default in C:\xamppwin\htdocs\phalcon\app\config\services.php:6 Stack trace:
#0 [internal function]: Phalcon\Di->__construct()
#1 C:\xamppwin\htdocs\phalcon\app\config\services.php(6): Phalcon\Di\FactoryDefault->__construct()
#2 C:\xamppwin\htdocs\phalcon\public\index.php(21): require('C:\\xamppwin\\htd...')
#3 {main} thrown in C:\xamppwin\htdocs\phalcon\app\config\services.php on line 6
//services.php line 6
$di = new \Phalcon\DI\FactoryDefault();

googlle avatar Jul 31 '16 20:07 googlle

This is a really strange error. I am using Phalcon 3 on Windows 10, PHP 7.0.8 x64, and similar errors do not occur.

Studentsov avatar Jul 31 '16 21:07 Studentsov

Try to reload the page many times and the error should appear

googlle avatar Jul 31 '16 21:07 googlle

Are you using maybe opcache ? Try to check it disabled for instance.

Jurigag avatar Jul 31 '16 21:07 Jurigag

This seems to be affecting only Windows installations, I'll have to set up a Windows environment to check

andresgutierrez avatar Aug 01 '16 01:08 andresgutierrez

I have the same error. My env: Win 10 x64 + Apache 2.4.23 + PHP 7.0.9 x64 ZTS. Also tried Apache 2.4.18, PHP 7.0.8 x86 ZTS, PHP 7.0.8 x64 ZTS. This error only happens when a lot of requests come. Just create an "index.php" with 2 lines:

use Phalcon\Di\FactoryDefault;
$di = new FactoryDefault();

And keep refreshing this page or use apache ab.exe: ab -n 100 -c 10 "http://localhost/index.php" Then you can see this error in php_error.log.

Update: I tried nginx+php and php cli mode(5.6.19, 7.0.8, 7.0.9), no error appeared. I think this only affects apache+php.

toddlxt avatar Aug 01 '16 04:08 toddlxt

As i wrote, did you have opcache enabled ? Can you disable it for instance ?

Jurigag avatar Aug 01 '16 07:08 Jurigag

I've also got the same issue with WAMP3, (Which uses Apache) PHP 7.0.4 (TS). Haven't checked if opcode caching is enabled by default, and I haven't tried compiling Phalcon myself yet, but I'll try it tonight and see if it makes a difference.

VeryStrongFingers avatar Aug 01 '16 07:08 VeryStrongFingers

@Jurigag After I set opcache.enable=0 in php.ini and restarted apache, I still got this error. In phpinfo():

Opcode Caching  |   Disabled
Optimization    |   Disabled
SHM Cache       |   Enabled
File Cache      |   Disabled

Do you need me to do more tests?

Update: I set opcache.enable=1 to enable opcache, still got the error.

toddlxt avatar Aug 01 '16 07:08 toddlxt

No, i just thought it might be opcache, but looks like not.

Jurigag avatar Aug 01 '16 07:08 Jurigag

Yet another Window$ dev environment with strange behaviour.

I wouldn't consider this as a bug unless the issue can be reproduced on production system (i.e. GNU/Linux).

IMHO, just like Phalcon 3.0.0 has dropped support for Oracle RDBMS due to the noted reasons, same should have happened with DLL / Microsoft support.

stamster avatar Aug 01 '16 21:08 stamster

@stamster why?

andresgutierrez avatar Aug 01 '16 21:08 andresgutierrez

@stamster well, more interesting is that @Studentsov don't have this problem ? :D

Sometimes people just want to use phalcon on their dev enviroment without using any virutal machine.

Jurigag avatar Aug 01 '16 21:08 Jurigag

For example, I prefer to program in Windows because switching PHP versions, web servers and DBMS I make one click. Isn't that progress? :D Seriously, I am aware of the possible differences of behaviour, so always spend additional testing on a production-like environment. Error when using PHP 7 with Apache I have neither...

Studentsov avatar Aug 03 '16 10:08 Studentsov

Studentsov - i make the same on linux:

phpbrewswitch 7.0.5
phpbrewswitch 5.6.19

Just phpbrew and proper script.

Jurigag avatar Aug 03 '16 13:08 Jurigag

http://stackoverflow.com/questions/38235349/fatal-error-access-to-undeclared-static-property-phalcon-di-default-pub https://github.com/owncloud/core/issues/22370 Definitely something not related to the framework but the PHP or PHP setup I guess

makerlabs avatar Aug 06 '16 09:08 makerlabs

same error occurs in: Phalcon version:3.0.0 PHP Version:7.0.10 Operating System:Windows 10 / Apache 2.4 x86 (php7_module) / PHP 7.0.10 x86

pedro151 avatar Aug 24 '16 17:08 pedro151

As you see above it's not phalcon problem really.

Jurigag avatar Aug 24 '16 17:08 Jurigag