Downloads
Stars
Version
This package comes with a LaravelEnvScanner
class and artisan command which you can use to scan any folder in your app for potential .env related problems.
Example output of the command:
php artisan env:scan
Scanning: laravel-app/config...
2 undefined variable(s) found in laravel-app/config/...
+-------------------------------+----------+
| laravel-app/config/app.php:16 | APP_NAME |
| laravel-app/config/app.php:29 | APP_ENV |
+-------------------------------+----------+
You can install the package via composer:
composer require mtolhuys/laravel-env-scanner
You can call the artisan command to start the scan:
php artisan env:scan
Optionally you could specify a directory to run from (defaults to config_path()
):
php artisan env:scan -d app/Http/Controllers
Scanning: app/Http/Controllers...
Or show all used variables:
php artisan env:scan -a
Scanning: laravel-app/config...
+------------------------------------+----------------+---------------------------+-------------------+
| Locations (2) | Defined (1) | Depending on default (1) | Undefined (0) |
+------------------------------------+----------------+---------------------------+-------------------+
| laravel-app/config/database.php:36 | DB_CONNECTION | - | - |
| laravel-app/config/database.php:42 | - | DB_HOST | - |
+------------------------------------+----------------+---------------------------+-------------------+
php artisan env:scan -d app
Scanning: app...
Warning: env("RISKY_".$behavior) found in app/Http/Middleware/Authenticate.php
php artisan env:scan -d storage
Scanning: storage...
Looking good!
Aside from the command you can use the LaravelEnvScanner
from anywhere you want:
(new LaravelEnvScanner(__DIR__))->scan()->results;
// Or
$this->scanner = new LaravelEnvScanner(__DIR__);
$this->scanner->scan();
$this->scanner->results;
// Example results
[
"locations" => 1
"defined" => 1
"undefined" => 0
"depending_on_default" => 0,
"columns" => [
0 => [
"location" => "laravel-app/config/database.php:36"
"defined" => "DB_HOST"
"depending_on_default" => "-"
"undefined" => "-"
]
]
]
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.