diff --git a/composer.json b/composer.json index ad27c9a..c109d73 100644 --- a/composer.json +++ b/composer.json @@ -11,9 +11,9 @@ } ], "require": { - "php": ">=5.4.0", - "illuminate/support": "^5.0,<5.7", - "browscap/browscap-php": "^3.1" + "php": ">=7.1.0,<7.3.0", + "illuminate/support": "~5.0", + "browscap/browscap-php": "~4.0" }, "autoload": { "psr-4": { diff --git a/config/browscap.php b/config/browscap.php index 7b79c61..4cd1057 100644 --- a/config/browscap.php +++ b/config/browscap.php @@ -12,7 +12,7 @@ | Full_PHP_BrowscapINI | */ - 'remote-file' => 'PHP_BrowscapINI', + 'remote-file' => env('BROWSCAP_REMOTE_FILE', 'PHP_BrowscapINI'), /* |-------------------------------------------------------------------------- diff --git a/src/BrowscapServiceProvider.php b/src/BrowscapServiceProvider.php index d2e62a5..9283c40 100644 --- a/src/BrowscapServiceProvider.php +++ b/src/BrowscapServiceProvider.php @@ -1,11 +1,17 @@ setupConfig(); } @@ -30,22 +36,26 @@ public function boot() * * @return void */ - public function register() + public function register(): void { - $this->app->singleton('browscap', function () { - $bc = new Browscap(); - $adapter = new File([File::DIR => config('browscap.cache')]); - $bc->setCache($adapter); + $this->app->singleton('browscap', function (ApplicationContract $app) { + $cache = new SimpleCacheAdapter( + new FilesystemCache(config('browscap.cache')) + ); + $bc = new Browscap( + $cache, + $app->make('log')->driver() + ); return $bc; }); + $this->app->bind(BrowscapInterface::class, 'browscap'); if ($this->app->runningInConsole()) { $this->commands([ Console\CheckUpdateCommand::class, Console\ConvertCommand::class, Console\FetchCommand::class, - Console\LogfileCommand::class, Console\ParserCommand::class, Console\UpdateCommand::class, ]); @@ -57,14 +67,14 @@ public function register() * * @return array */ - public function provides() + public function provides(): array { return ['browscap']; } protected function setupConfig() { - $source = dirname(__DIR__) . '/config/browscap.php'; + $source = realpath($raw = __DIR__.'/../config/browscap.php') ?: $raw; if ($this->app instanceof LaravelApplication) { $this->publishes([$source => config_path('browscap.php')]); diff --git a/src/Console/CheckUpdateCommand.php b/src/Console/CheckUpdateCommand.php index e849a21..54e7e7f 100644 --- a/src/Console/CheckUpdateCommand.php +++ b/src/Console/CheckUpdateCommand.php @@ -1,4 +1,8 @@ -getDefinition()->getOption('remote-file')->setDefault(config('browscap.remote-file')); diff --git a/src/Console/LogfileCommand.php b/src/Console/LogfileCommand.php deleted file mode 100644 index fb799f5..0000000 --- a/src/Console/LogfileCommand.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ -class LogfileCommand extends Command -{ - /** - * Create a new command instance. - * - * @return void - */ - public function __construct() - { - parent::__construct(config('browscap.cache')); - - // allocate necessary resources for the possible pick usage during parsing/caching of browscap.ini database file - ini_set('memory_limit', '512M'); - } -} diff --git a/src/Console/ParserCommand.php b/src/Console/ParserCommand.php index f7264d9..33e5c73 100644 --- a/src/Console/ParserCommand.php +++ b/src/Console/ParserCommand.php @@ -1,4 +1,8 @@ -