Fatal error: Uncaught Error: Class 'COM' not found with PHP 7.2.x

Asked

Viewed 1,781 times

0

Someone would tell me how to solve this problem?

When I access my local address of my website, it returns this message "Fatal error: Uncaught Error: Class 'COM' not found". This message is only returned when I try to use PHP 7.2.1, as I am trying to update the PHP version.

When PHP version 7.1.x is working normally.

I already put the DLL "php_com_dotnet.dll" in PHP ext.

  • already put in php.ini too? extension=php_com_dotnet.dll

  • I put yes...

  • Restarted the server? The php.ini that you changed is the same that appears in Loaded Configuration File when using <?php phpinfo();?

  • I restarted yes... It is this php.ini yes

1 answer

2

Things have changed in PHP7.2

Extensions in php.ini as

 extension=php_com_dotnet.dll

It was a used format up to PHP7.1, but from PHP7.2 all extensions now use a format like these:

extension=com_dotnet

Without the prefix php_ and without the extension .dll, of course in the folder ./ext should still be keep the names with the formats php_<extensão>.dll or on linux <extensão>.so, but in php.ini (from 7.2 onwards) this is already implicit, ie only the name will already recognize.

Just like in other extensions it must be something like:

extension=mysqli

Instead of:

extension=php_mysqli.dll

And instead of (on Linux and Mac)

extension=mysqli.so

This was probably done to make php.ini more "portable", as described in php.ini of PHP7.2 onwards:

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

; If you wish to have an extension loaded automatically, use the following
; syntax:
;
;   extension=modulename
;
; For example:
;
;   extension=mysqli
; 

This PHP7.2 format is used on both Windows and Linux and Mac

Even I always guide in all my answers about the differences of Linux (and Mac), Windows and PHP7.2, for example:

  • I put as you said but kept giving the error, picked up and updated to PHP 7.2.2... But it presented this error "Warning: Use of Undefined Constant MSSERVER - assumed 'MSSERVER' (this will throw an Error in a Future version of PHP)"... You know what it could be?

  • 1

    @Lucassouza the MSSERVER was written in your script? This seems wrong in your script and not in the activation of the extension.

  • No. It is a file . inc that has the $Tipodbconf variable assigning the MSSERVER value

  • 1

    @Lucassouza this MSSERVER is probably some obsolete code you picked up from somewhere and has no relation to the extension problem.

  • Ok... Thank you William!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.