Strange error after migration to Phalcon 3.0.0
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!
My only guess it's beacause of windows perhaps ? Works on vagrant/ubuntu 14.04 without any problem.
What is $config?
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();
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.
Try to reload the page many times and the error should appear
Are you using maybe opcache ? Try to check it disabled for instance.
This seems to be affecting only Windows installations, I'll have to set up a Windows environment to check
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.
As i wrote, did you have opcache enabled ? Can you disable it for instance ?
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.
@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.
No, i just thought it might be opcache, but looks like not.
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 why?
@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.
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 - i make the same on linux:
phpbrewswitch 7.0.5
phpbrewswitch 5.6.19
Just phpbrew and proper script.
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
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
As you see above it's not phalcon problem really.