lightship-core / lightship-laravel
Laravel wrapper to use Lightship PHP.
Requires
- illuminate/console: 9.*
- illuminate/support: 9.*
- lightship-core/lightship-php: ^0.9.0
Requires (Dev)
- friendsofphp/php-cs-fixer: 3.13.0
- nunomaduro/collision: 6.3.1
- orchestra/testbench: 7.15.0
- phpstan/phpstan: 1.9.2
- thibautselingue/local-php-security-checker-installer: 1.0.3
- dev-master
- 0.4.0
- 0.3.1
- 0.3.0
- 0.2.0
- 0.1.0
- dev-14-add-indexes-to-examples
- dev-21-add-rector
- dev-24-fix-php-stan-missin-xdebug-flag-warning
- dev-23-add-composer-command-to-run-all-tests-at-once
- dev-18-use-composer-audit-instead-of-symfony-security-checker
- dev-17-support-for-php-8-2
- dev-11-add-detailed-command-option
This package is auto-updated.
Last update: 2024-11-17 02:05:45 UTC
README
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
1. Using the facade
In this example, we will generate an array report using the Laravel facade.
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, ]); } }
2. 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.
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"]), ] ]); } }
3. 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
:
use Illuminate\Support\Facades\Artisan; // ... Artisan::call("lightship:run", [ "--route" => "home.index", "--detailed" => true, ]);
Tests
composer check-platform-reqs
composer install
composer run analyse
composer run test
composer run lint
composer run scan
composer run check
composer run updates
Or
composer run all