Laravel wrapper to use Lightship PHP

Last update: May 8, 2022

lightship-laravel

Laravel wrapper to use Lightship PHP.

Summary

About

Lightship is a way to get web page audits without using a headless browser.

This package just a wrapper around the PHP implementation of Lightship (https://github.com/lightship-core/lightship-php).

Features

  • Provides a Facade to easily use Lightship PHP

Installation

On your terminal, install the package:

composer require --dev lightship-core/lightship-laravel

Examples

Using the facade

In this example, we will generate an array report using the Laravel facade.

analyse() ->toArray(); return view("home.index", [ "report" => $report, ]); } }">
namespace App\Controllers;

use Lightship\Facades\Lightship;

class HomeController extends Controller
{
  public function index()
  {
    $report = Lightship::route("https://example.com")
      ->analyse()
      ->toArray();

    return view("home.index", [
      "report" => $report,
    ]);
  }
}

Using the comand

In this example, we will call Lightship from the command.

php artisan lightship:run --url https://example.com

You can also pass a route name.

php artisan lightship:run --route home.index

You can even pass multiple routes.

php artisan lightship:run --route home.index --route contact-us.index

And you can mix both.

php artisan lightship:run --route home.index --route contact-us.index --url https://example.com --url https://google.com

Since the command do not support passing query strings, you can do it by creating your own command and call this one.

[ route("home.index", ["lang" => "en"]), route("contact-us.index", ["theme" => "dark"]), ] ]); } }">
namespace App\Console\Commands;

use Illuminate\Console\Command;

class MyCommand extends Command
{
  protected $signature = 'my-command:run';

  protected $description = 'Scan my routes.';

  public function handle()
  {
    $this->call("lightship:run", [
      "--url" => [
        route("home.index", ["lang" => "en"]),
        route("contact-us.index", ["theme" => "dark"]),
      ]
    ]);
  }
}

Show failed/passed rules when using the command

By default, the command does not show the failed/passed rules of each URLs to save some space. If you want to show the detail, use the --detailed option.

php artisan lightship:run --route home.index --detailed

Or by calling Artisan::call:

"home.index", "--detailed" => true, ]);">
use Illuminate\Support\Facades\Artisan;

// ...

Artisan::call("lightship:run", [
  "--route" => "home.index",
  "--detailed" => true,
]);

Tests

composer check-platform-reqs
composer install
composer run install-security-checker
composer run analyse
composer run test
composer run lint
composer run security-check
composer run update-check

GitHub

https://github.com/lightship-core/lightship-laravel
Comments
  • 1. Cannot access protected property Lightship\Report::$durationInSeconds

    When using php artisan lightship:run --url example.com I get error:

    Cannot access protected property Lightship\Report::$durationInSeconds

    at vendor/lightship-core/lightship-laravel/src/Commands/LightshipRun.php:168

    That var appear to be public: https://raw.githubusercontent.com/lightship-core/lightship-php/master/src/Report.php on last version but not on the 0.5.0 that has been installed.

    using PHP 8.1.3

    Reviewed by Spir at 2022-05-05 15:07
  • 2. 11-add-detailed-command-option

    Added

    • New --detailed option to the command to show failed/passed rules

    Fixed

    N/A

    Breaked

    • lightship:run does not shows failed/passed rules by default
    Reviewed by khalyomede at 2022-05-08 08:31
  • 3. Add --detailed command option

    When activated, the rules that have failed/passed are show below the site/URL. By default, only the URL/route and the scores are being printed on console.

    Reviewed by khalyomede at 2022-05-05 21:32
  • 4. Fix Composer warning

    Class Tests\Feature\Facades\LightshipRunTest located in ./vendor/lightship-core/lightship-laravel/tests/Feature/Commands/LightshipRunTest.php does not comply with psr-4 autoloading standard. Skipping.

    Reviewed by khalyomede at 2022-05-05 21:20
  • 5. 7-wrong-passed-failed-total

    Added

    N/A

    Fixed

    • Failed URLs/routes are now considered failed and will correctly be counted as it on the summary when running lightship:run

    Breaked

    N/A

    Reviewed by khalyomede at 2022-05-05 21:12
  • 6. Add indexes to examples

    Currently:

    - [Using the facade](#using-the-facade)
    - [Using the comand](#using-the-comand)
    

    Expected

    - [1. Using the facade](#2-using-the-facade)
    - [2. Using the comand](#1-using-the-comand)
    
    Reviewed by khalyomede at 2022-05-08 08:11
  • 7. Visual revamp using nunomaduro/termwind

    • Display ok/ko (green/red) before each URL/route name
    • Display scores with
      • red if < 35
      • orange between 35 and 89
      • green if >= 90
    • ok/ko (green/red) before each passing/failed rules
    • grey for http:// or https://, white for website path/query strings
    Reviewed by khalyomede at 2022-05-05 21:38
A simple to use query builder for the jQuery QueryBuilder plugin for use with Laravel.
A simple to use query builder for the jQuery QueryBuilder plugin for use with Laravel.

QueryBuilderParser Status Label Status Value Build Insights Code Climate Test Coverage QueryBuilderParser is designed mainly to be used inside Laravel

Jan 25, 2022
A Laravel package that allows you to use multiple ".env" files in a precedent manner. Use ".env" files per domain (multi-tentant)!
A Laravel package that allows you to use multiple

Laravel Multi ENVs Use multiple .envs files and have a chain of precedence for the environment variables in these different .envs files. Use the .env

May 5, 2022
A super simple package allowing for use MySQL 'USE INDEX' and 'FORCE INDEX' statements.
A super simple package allowing for use MySQL 'USE INDEX' and 'FORCE INDEX' statements.

Laravel MySQL Use Index Scope A super simple package allowing for use MySQL USE INDEX and FORCE INDEX statements. Requirements PHP ^7.4 | ^8.0 Laravel

Feb 21, 2022
Mollie API client wrapper for Laravel & Mollie Connect provider for Laravel Socialite
Mollie API client wrapper for Laravel & Mollie Connect provider for Laravel Socialite

Mollie for Laravel Laravel-Mollie incorporates the Mollie API and Mollie Connect into your Laravel or Lumen project. Accepting iDEAL, Apple Pay, Banco

May 3, 2022
A Laravel Wrapper for the CoinDCX API. Now easily connect and consume the CoinDCX Public API in your Laravel apps without any hassle.
A Laravel Wrapper for the CoinDCX API. Now easily connect and consume the CoinDCX Public API in your Laravel apps without any hassle.

This package provides a Laravel Wrapper for the CoinDCX API and allows you to easily communicate with it. Important Note This package is in early deve

Feb 16, 2022
27Laracurl Laravel wrapper package for PHP cURL class that provides OOP interface to cURL. [10/27/2015] View Details

Laracurl Laravel cURL Wrapper for Andreas Lutro's OOP cURL Class Installation To install the package, simply add the following to your Laravel install

Sep 9, 2018
A CommonMark wrapper for Laravel
A CommonMark wrapper for Laravel

Laravel Markdown Laravel Markdown was created by, and is maintained by Graham Campbell, and is a CommonMark wrapper for Laravel. It ships with integra

May 20, 2022
Laravel wrapper package for the Aimon.it API

Laravel Aimon Package A laravel wrapper package for the Aimon.it API. For more information see Aimon Requirements Laravel 6 or later Installation Inst

Feb 5, 2022
PayuMoney Gateway wrapper for Laravel.
PayuMoney Gateway wrapper for Laravel.

PayuMoney Integration with Laravel Easy to use integration for PayUMoney into Laravel apps. Video Tutorial Usage composer require infyomlabs/laravel-p

Mar 2, 2022
A Laravel wrapper for spatie/dns. Allows to query and validate DNS records.

A Laravel wrapper for spatie/dns. Allows to query and validate DNS records.

Apr 16, 2022
Laravel API wrapper to interact fluently with your Janus Media Server

Laravel API wrapper to interact fluently with your Janus Media Server. Core server interactions, as well as the video room plugin included.

Apr 18, 2022
A laravel wrapper for BnpParibas Mercanet payment gateway
A laravel wrapper for BnpParibas Mercanet payment gateway

Laravel Mercanet A laravel wrapper for BnpParibas Mercanet which provide a lightweight public api to process your online payments from your laravel ap

May 4, 2022
Open Food Facts API wrapper for Laravel

Laravel Open Food Facts API This package provides a convenient wrapper to the Open Food Facts API for Laravel applications (5.7+). Installation You ca

May 18, 2022
a Google API v3 wrapper for Laravel 4.x

A Google API v3 wrapper for Laravel 4 This package enables a Laravel flavoured way to manage Google services through its API interface (v3) Installati

May 14, 2021
Laravel wrapper for Sentry Official API

Laravel Sentry API Provides a simple laravel wrapper to some of the endpoints listed on (Official Sentry API)[https://docs.sentry.io/api/]. **Note: Th

Nov 1, 2021
A wrapper package to run mysqldump from laravel console commands.

A wrapper package to run mysqldump from laravel console commands.

Dec 13, 2021
Laravel wrapper for the Gmail API

Laravel Gmail Gmail Gmail API for Laravel 8 You need to create an application in the Google Console. Guidance here. if you need Laravel 5 compatibilit

May 24, 2022
Laravel wrapper for zendesk/zendesk_api_client_php package.

Laravel Zendesk This package provides integration with the Zendesk API. It supports creating tickets, retrieving and updating tickets, deleting ticket

Mar 15, 2022
A DOMPDF Wrapper for Laravel

DOMPDF Wrapper for Laravel Laravel wrapper for Dompdf HTML to PDF Converter Require this package in your composer.json and update composer. This will

May 20, 2022