You can install this package through Composer.
- First, edit your project's
composer.json
file to requireerdaldemirci/laravel-geoip-log-cleaner
:
"require": {
// other require packages
"laravel-geoip-log-cleaner": "1.*"
},
- Next, run the composer update command in your command line interface:
$ composer update
Note: Instead of performing the above two steps, you can perform faster with the command line
$ composer require erdaldemirci/laravel-geoip-log-cleaner:1.*
.
- Add following code to app\Console\Kernel.php.
protected $commands = [
// other kernel commands
\ErdalDemirci\GeoIPLogCleaner\Command\LogClearCommand::class,
];
Laravel Log Cleaner has a facade with name is ErdalDemirci\GeoIPLogCleaner\Facades\Cleaner
. You can do any operation through this facade. For example:
<?php
namespace YourNamespace;
// your code
use ErdalDemirci\GeoIPLogCleaner\Facades\Cleaner;
class YourClass
{
public function yourMethod()
{
Cleaner::doSomething();
}
}
Some functions of loading, writing, backing up, restoring are implementation and usage of method chaining. So these functions can be called to chained together in a single statement. Examples:
$cleaner = Cleaner::rotate(14);
if ($cleaner->clear()) {
echo 'GeoIP Log files older than 14 days in default folder were cleared successfully.';
} else {
echo 'GeoIP Log files older than 14 days in default folder were cleared with errors.';
}
if ($cleaner->dir('path_to_logs')->clear()) {
echo 'GeoIP Log files older than 14 days in `path_to_logs` folder were cleared successfully.';
} else {
echo 'GeoIP Log files older than 14 days in `path_to_logs` folder were cleared with errors.';
}
if (Cleaner::dir('path_to_logs')->clear()) {
echo 'Log files in `path_to_logs` folder were cleared successfully.';
} else {
echo 'Log files in `path_to_logs` folder were cleared with errors.';
}
Laravel GeoIP Log Cleaner have command can use easily with Artisan CLI. Example:
$ php artisan geoiplog:clear --path=/path/to/log/files --rotate=14
Please use each above command with option --help for details of usage. Example:
$ php artisan geoiplog:clear --help
The Laravel GeoIP Log Cleaner is open-source software licensed under the MIT license.
Hopefully, this package is useful to you.