Class Not Found
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.
-
I've uninstalled cmdtest and installed yarn properly instead.
-
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 } -
I've run the index.php file and it still won't work
-
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?
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.
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.