Create Lighthouse Tools
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3555712. --> Reported by: [marcus_johansson](https://www.drupal.org/user/385947) >>> <h3>Summary</h3> <p>We will create an initial Lighthouse integration module for Tool API (<a href="https://www.drupal.org/project/tool">https://www.drupal.org/project/tool</a>) that executes Lighthouse audits using the Spatie lighthouse-php library (<a href="https://github.com/spatie/lighthouse-php">https://github.com/spatie/lighthouse-php</a>). The module will expose reusable tools to run audits and extract key metrics. Tools will be placed under src/Plugin/tool/Tool. No authentication is required.</p> <h3>Remaining tasks</h3> <ul> <li>Composer and library setup <ul> <li>Add composer dependency: spatie/lighthouse-php.</li> <li>Verify PHP environment compatibility.</li> <li>Confirm the library executes Lighthouse without Node installation.</li> </ul> </li> <li>Configuration UI <ul> <li>Create a settings form at /admin/config/services/lighthouse-integration.</li> <li>Provide field for optional Lighthouse config JSON path.</li> <li>Add validation for config file path if provided.</li> </ul> </li> <li>Permissions and menu <ul> <li>Define permission: &ldquo;Administer Lighthouse integration tools&rdquo;.</li> <li>Add menu link under Configuration &rarr; Services &rarr; Lighthouse Integration.</li> <li>Restrict access to settings form by permission.</li> </ul> </li> <li>Tool API plugins (stored in src/Plugin/tool/Tool) <ul> <li><strong>Run Lighthouse Audit</strong> <ul> <li>Input: url (string, required).</li> <li>Input: categories (array of strings, optional; default all categories).</li> <li>Output: report_json (object).</li> <li>Output: score_overall (float).</li> <li>Output: score_accessibility (float).</li> <li>Output: score_performance (float).</li> <li>Output: score_seo (float).</li> <li>Output: score_best_practices (float).</li> </ul> </li> <li><strong>Extract Lighthouse Metrics</strong> <ul> <li>Input: report_json (object, required).</li> <li>Output: first_contentful_paint (float).</li> <li>Output: largest_contentful_paint (float).</li> <li>Output: total_blocking_time (float).</li> <li>Output: cumulative_layout_shift (float).</li> <li>Output: time_to_interactive (float).</li> </ul> </li> <li><strong>Export Lighthouse Report</strong> <ul> <li>Input: report_json (object, required).</li> <li>Input: format (string, required; json or html).</li> <li>Output: file_uri (string).</li> </ul> </li> </ul> </li> <li>Implementation details <ul> <li>Add tool classes under src/Plugin/tool/Tool/Lighthouse*.</li> <li>Call Spatie Lighthouse library runner with optional custom config.</li> <li>Parse result object into Tool API output structures.</li> <li>Handle and report execution errors.</li> </ul> </li> <li>Documentation <ul> <li>Provide composer install instructions.</li> <li>Document tools, inputs, and outputs.</li> </ul> </li> </ul> <p><strong>This issue was generated with the help of AI, but vetted before publishing.</strong></p>
issue