lighthouse-php icon indicating copy to clipboard operation
lighthouse-php copied to clipboard

Class Not Found

Open dbee01 opened this issue 5 years ago • 2 comments

So when i try to run a set-path.php file I get...

dara@laptop-20-04:~/Desktop/light-house$ php light-house/set-path.php PHP Fatal error: Uncaught Error: Class 'Dzava\Lighthouse\Lighthouse' not found\ in /home/dara/Desktop/light-house/light-house/set-path.php:4 Stack trace: #0 {main} thrown in /home/dara/Desktop/light-house/light-house/set-path.php on line 4

With set-path.php looking like this...

`<?php use Dzava\Lighthouse\Lighthouse;

(new Lighthouse()) ->setNodeBinary('/usr/bin/node') ->setLighthousePath('./node_modules/lighthouse/lighthouse-cli/index.js') ->audit('https://mysite.com'); `

What I've tried so far.

  1. I've uninstalled cmdtest and installed yarn properly instead.

  2. I've replaced the composer.json file and ran a composer require { "repositories": [ { "type": "vcs", "url": "https://github.com/dzava/lighthouse-php" } ], "require": { "dzava/lighthouse": "dev-master" }, "minimum-stability": "dev", "prefer-stable": true }

  3. I've run the index.php file and it still won't work

  4. I've run an audit-fail.php file to troubleshoot. It returns but doesn't throw up any errors. No output whatsoever.

`<?php require "./vendor/autoload.php";

use Dzava\Lighthouse\Exceptions\AuditFailedException; use Dzava\Lighthouse\Lighthouse;

try { (new Lighthouse()) ->performance() ->audit('https://mysitecom'); } catch(AuditFailedException $e) { echo $e->getOutput(); }

`

Where exactly is dzava/lighthouse?

dbee01 avatar Nov 08 '21 06:11 dbee01

Looks like your set-path file is missing the line require "./vendor/autoload.php"; Since there are no errors/output when running the audit-fail file, i would guess that the audit was run successfully. dzava/lighthouse is the package name in the composer registry.

dzava avatar Nov 08 '21 18:11 dzava

Right. thanks. So i get a successful response when i run index.php like so...

`<?php require('./vendor/autoload.php');

use Dzava\Lighthouse\Lighthouse;

(new Lighthouse()) ->setOutput('report.json') ->accessibility() ->bestPractices() ->performance() ->pwa() ->seo() ->audit('https://mysite.com'); `

Thanks.

dbee01 avatar Nov 09 '21 05:11 dbee01