Laravel wrapper to use Lightship PHP

Overview

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
Comments
  •   Cannot access protected property Lightship\Report::$durationInSeconds

    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

    bug 
    opened by Spir 5
  • 11-add-detailed-command-option

    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
    enhancement 
    opened by khalyomede 0
  • Add --detailed command option

    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.

    enhancement 
    opened by khalyomede 0
  • Fix Composer warning

    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.

    bug 
    opened by khalyomede 0
  • 7-wrong-passed-failed-total

    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

    bug 
    opened by khalyomede 0
  • Add custom TestCase assertions

    Add custom TestCase assertions

    Example

    class HomeControllerTest extends TestCase 
    {
      public function testHomeHaveLang() 
      {
        $this->get(route("home.index"))
          ->assertHasLangAttribute();
      } 
    } 
    
    opened by khalyomede 0
  • Add indexes to examples

    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)
    
    documentation good first issue 
    opened by khalyomede 0
  • Visual revamp using nunomaduro/termwind

    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
    enhancement 
    opened by khalyomede 0
Owner
Lightship
Web performance/seo/security audit browser-less.
Lightship
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

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

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

Allyson Silva 48 Dec 29, 2022
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

Vasyl 29 Dec 27, 2022
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

Mollie 289 Nov 24, 2022
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

Moinuddin S. Khaja 2 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

zjango 8 Sep 9, 2018
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

Graham Campbell 1.2k Jan 2, 2023
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

Ruslan 3 Aug 7, 2022
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

InfyOmLabs (InfyOm Technologies) 10 Nov 29, 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.

Astrotomic 22 Nov 17, 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.

Richard  Tippin 11 Aug 21, 2022
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

Mouad ZIANI 29 Nov 27, 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

Open Food Facts 112 Jan 4, 2023
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

null 4 Nov 29, 2022
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

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

A wrapper package to run mysqldump from laravel console commands.

Yada Khov 24 Jun 24, 2022
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

Daniel Castro 244 Jan 3, 2023
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

Huddle Digital 97 Dec 22, 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

Barry vd. Heuvel 5.6k Dec 25, 2022