Lock Lock - 3 months ago 10
PHP Question

How do I use the COM library in Laravel?

How do I use the COM library in Laravel?
I've got the following:

$connection = new COM("ADODB.Connection");


However, I get the following error:

Class 'App\COM' not found

Answer

Your code is using the App namespace; and there is no COM class defined within the App namespace. The standard PHP COM class exists within the global namespace, so you need to specify that this is where the class should be found.

Use

$connection = new \COM("ADODB.Connection");

The leading \ tells PHP to look for the class in the global namespace

Comments