Home > Back-end >  php HeadlessChromium\BrowserFactory not found in file.php
php HeadlessChromium\BrowserFactory not found in file.php

Time:05-11

<?php
use HeadlessChromium\BrowserFactory;

$browserFactory = new BrowserFactory();

?>

I've installed chrome-php/chrome with composer and hovering my mouse over the class will give me the details but when I try to run the code I get the error:

PHP Fatal error:  Uncaught Error: Class 'HeadlessChromium\BrowserFactory' not found in file.php

Is there something I'm missing in the initial set up? Not sure why it isn't working. I'm using visual studio code and the bug appears in the debug console tab instead of the problems tab. I'm not getting any issues in the problems tab. Any idea why that is the case?

CodePudding user response:

When using composer you need to include the autoloader on top of the script.

<?php
require __DIR__ . '/vendor/autoload.php';

use HeadlessChromium\BrowserFactory;

$browserFactory = new BrowserFactory();
  • Related