I just had this error when I updated to PHP 8.1:
Fatal Error: Cannot use 'Object' as a class name as it is reserved on line 77
I guess it used a reserved word as an actual class. How can I solve this?
The solution depends where exactly the error occurs.
Error is in file that belongs to Yii framework itself
You have to upgrade framework to newer version. Version 2.0.13 introduced yii\base\BaseObject as base class instead of yii\base\Object.
Error is in some 3rd party library
You have to look for upgrade of that library.
Error is in class that belongs directly to your application
That probably means that your class extends yii\base\Object. You have to modify classes like that to extend yii\base\BaseObject instead. This requires the version of Yii framework to be at least 2.0.13. But because the error didn't occur in framework its version should be probably ok.
You need to follow the instructions on this page to upgrade.
For example, to use php 7, 8, you must follow the instructions in this section.
For compatibiliy with PHP 7.2 which does not allow classes to be named Object anymore, we needed to rename yii\base\Object to yii\base\BaseObject.
This also applies to php 8.
Upgrade from Yii 2.0.12
If you want to upgrade PHP to version 7.2 in your project you need to remove all cases that extend yii\base\Object and extend from yii\base\BaseObject instead:
Good luck
Related
I've been developing my PHP Apps based on ezSQL class since 2000s. Unfortunately, I have depended on this class ever since. It was fine until I realized that this class isn't valid for servers running PHP 7+. When I run my App on servers running PHP 5.6 and below it works fine. Any other version above PHP 5.6 would give me this error:
Fatal Error: ezSQL_mysql requires mySQL Lib to be compiled and or linked in to the PHP engine
Unfortunately, the one who did this great class isn't working on it anymore since a long time. Is there any way around to fix this?
You are probably using the old ezSQL class, it uses libmysqlclient. PHP 7 no longer uses libmysqlclient, leaving the old version of ezSQL useless. Upgrade to the new version of ezSQL or access this project that updated the old class adapted for MySQLi.
i have a problem with some old TYPO3 stuff, i tried to make a old TYPO3 Website run on my Ubuntu system.
And sorry if somethings are not clear to understand for me, i am new in CMS's and i am forced to change some stuff on a old page.
Problems are:
1.
Backend seems working, half. If i enable the ext. TemplaVoila my be Page module shows me a white page.
On TV disable,
Page module, seems working but it gives me some strange error messages inside the content fields.
if i try to look at the front-end it gives me this exception:
1: PHP Runtime Deprecation Notice: Non-static method tx_ttnews_div::getSubCategories() should not be called statically,
assuming $this from incompatible context in
/var/www/projectfolder/projectfolder-typo3/typo3conf/ext/tt_news/pi/class.tx_ttnews.php
line 3740
Just apart from this, i read about a removed php feature in update 5.6 i was using currently.
Things i checked already:
-Correct PHP -v
-Database import correct
-LocalConf correct (took from live server and changed for my localhost)
-Checked install-tool and rm -rf * inside typo3temp folder
Thanks for you help
Your PHP version combined with the versions of TYPO3 and extensions seems to be incompatible. You either need to use a different PHP version or upgrade TYPO3 and/or the extensions being used. FYI, the method being called is from a very old extension so although you don't say which version you're using, I assume your TYPO3 version is very old (either 6.x or even 4.x versions).
The normal recommendation would be to upgrade TYPO3 and any extensions. The less recommended alternative would be to use a different PHP version. But please be aware that remaining on older TYPO3 versions means your site may not be patched for security issues and may not be compatible with modern browsers.
I have twig installed via composer on a new codebase I'm working on (OSX), and on a new server I was trying install my app on. I started getting a fatal error on twig_template_get_attributes()
namely
PHP Fatal error: Call to undefined function twig_template_get_attributes() in /<path_to_here>/templates_c/a2/4e/3fbd69b54a0875d7cd3744d62bf1fa98ed4e7b1b375f904ead10b7cb27b6.php
I don't have this problem locally (OSX), and I was trying figure out why this is happening on my other server (Ubuntu 12.04 if that matters). When I install twig as a PHP extension the problem goes away, but my understanding is that the extension is completely optional and only optimizes one call
as per the documentation
The C extension is optional but it brings some nice performance
improvements. Note that the extension is not a replacement for the PHP
code; it only implements a small part of the PHP code to improve the
performance at runtime; you must still install the regular PHP code.
and
And from now on, Twig will automatically compile your templates to
take advantage of the C extension. Note that this extension does not
replace the PHP code but only provides an optimized version of the
Twig_Template::getAttribute() method.
very confused about this behavior.
Using Laradock (basically a set og Docker images for Laravel development), I keep getting Class 'MongoId' not found FatalThrowableError errors when calling new \MongoId( $id ) in PHP.
This post Class 'MongoId' not found (Zend Framework with MongoDB Doctrine) suggests that the reason for given error is that the PHP Mongo extension isn't enabled.
However, if I look at the phpinfo() output, I can see mongodb section. Doesn't that mean it's enabled?
What else could possibly cause this error?
I assume that you are using php 7 version.
In php 7 version a new MongoDB extension is used.
So instead of legacy MongoId you should use MongoDB\BSON\ObjectID
I'm working with Zend Server CE on a Windows 7 (64bit) System.
I'm developing a website with Zend Framework 2.0. In this website I use DOMDocument to analyse an external website (given by URL).
I started this project with Zend Framework 1.12 and Zend Server CE 4 (PHP 5.2). Now I installed the Zend Server CE 5.6.0 (apache2.2, PHP 5.3.14, ZF2-Support). I rebuild my project with ZF2.0. Everything works fine...except one function.
I get this Error-Message (php-error.log), when I try to instantiate DOMDocument:
Fatal error: Class 'Application\Controller\DOMDocument' not found in
_Path_\module\Application\src\Application\Controller\SearchbarController.php on line 81
With PHP 5.2 (ZF 1.12) and Zend Server CE 4, this function worked perfectly. But now...without any change, it throws this error.
The dom-extension and the xml-extension are built-in in PHP 5.3. I checked phpinfo and my php.ini, that these extensions are running.
I read, that i should install php-xml. But dom, xml and libxml are running...why should i re-install them?
I don't know, why DOMDocument could not be instantiated after upgrading the Zend Server CE. May be, that the ZF2.0 is a possible reason for this error. But I can't find anything pointing to this.
In short, it's introduction of namespaces (feature of PHP 5.3 quite heavily used by ZF2 - but not ZF 1.x) that caused this bug. With this line...
$dom = new DOMDocument(...)
... only the currently imported namespace is checked for this class by ZF. And it results in failure, because DOMDocument class actually belongs to the global namespace.
The solution is simple, when you see the reason: use the global namespace specifier - \ symbol - in front of the class name. Like this:
$dom = new \DOMDocument(...)