Watching and observing requests, logs, and listed models to maintain all possible acivities.
margatampu/laravel-inspector is a Laravel package for watching and observing requests, logs, and listed models to maintain all possible acivities..
It currently has 0 GitHub stars and 69 downloads on Packagist (latest version v1.2.9).
Install it with composer require margatampu/laravel-inspector.
Discover more Laravel packages by margatampu
or browse all Laravel packages to compare alternatives.
Last updated
Watching and observing requests, logs, and listed models to maintain all possible activities. Laravel inspector use to do it and storing data in separate database.
Require this package with composer.
$ composer require margatampu/laravel-inspector
Package tested and worked with Laravel and Lumen framework (5.7+).
Laravel: After installation using composer finishes up, you'll have to add the following line to your config/app.php:
MargaTampu\LaravelInspector\InspectorServiceProvider::class
Lumen: For Lumen, you'll have to add the following line to your bootstrap/app.php:
$app->register(MargaTampu\LaravelInspector\InspectorServiceProvider::class);
Laravel: Then copy inspector config file from laravel-inspector to your config folder:
$ php artisan vendor:publish --provider="MargaTampu\LaravelInspector\InspectorServiceProvider"
Lumen: For Lumen, you need to copy file manually to your config folder and enable it in bootstrap/app.php:
$app->configure('inspector');
After configuration, migrate all necessary database structure from laravel-inspector with (prerequisite setting database in .env file):
$ php artisan migrate
To make sure laravel-inspector running securily, you need to generate inspector auth token using console command line with default value:
$ php artisan inspector:auth
It will generate a random key, and you need to store it in your .env file.
Last step for your integration, you need to add this line to your routes\api.php file to use laravel-inspector api route to handle storing data to database.
MargaTampu\LaravelInspector\Inspector::api();
For your models activity, you need to listing all your models you want to watched. Placed all your models in config\inspector.php file inside models element.
'models' => [
'App\User'
],
After installation and some integration, you need to update setup in your .env file. Besides database setting, you can add variable:
INSPECTOR_QUEUE_NAME, separate or merge inspector queue with your laravel default queue.INSPECTOR_LOG, to limit log level watched.INSPECTOR_MODEL_ENABLE, set to true to enable watched listed models.INSPECTOR_LOG_ENABLE, set to true to enable watched all log generated.INSPECTOR_REQUEST_ENABLE, set to true to enable watched request called.INSPECTOR_AUTHORIZATION, to store your generated auth token.Don't forgot to change your APP_URL as well with your current application domain url. It is use as api route url to store all your inspector data.
For expert use, you can ignore last step for integration steps for copying inspector API, and copied laravel-inspector api routes manually to your routes/api.php file and use your own controller to maintain data before store to database.
Then, you can store your destination url in .env file using this variables:
INSPECTOR_MODEL_ENDPOINT, full url to handle model inspector.INSPECTOR_LOG_ENDPOINT, full url to handle log inspector.INSPECTOR_REQUEST_ENDPOINT, full url to handle request inspector.If you plan to separate service and consumer, you can ignore migrations of inspector package to prevent project migrate unnecessary tables to your consumer database. You should call the Inspector::ignoreMigrations method in the register method of your AppServiceProvider.
To prevent inspector slowing your projects, you can queueing inspector jobs using separate queue name inspector. You can run single queue worker for it using this command:
$ php artisan queue:work --tries=1 --queue=inspector
To use this package, after all integration steps done. You will have your requests, logs and models activity in database.
You did run inspector:auth command before to generate new inspector default auth token. Beside it, we have several commands available:
You can custom your own inspector auth name using this command:
$ php artisan inspector:auth --new
You allowed to rename your existing inpector auth name using: Note: Replace {$id} with your inspector auth id
$ php artisan inspector:auth --name={$id}
Like inspector auth name, you also allowed to change token or refresh it using: Note: Replace {$id} with your inspector auth id
$ php artisan inspector:auth --refresh={$id}
For some laravel/lumen project, this package still not stable in some parts. If you want to test this package, you have several command to test it.
You can run a single command to run test all modules (model, log, and request).
$ php artisan inspector:test --all
Since you can enable and disable module in configuration file, you also enable to run single module too.
$ php artisan inspector:test --model
$ php artisan inspector:test --log
$ php artisan inspector:test --request
To ensure your package test module run smoothly, you need to recheck some configurations:
This laravel-teams-logging package is available under the MIT license. See the LICENSE file for more info.