Skip to content

Commit 9b899cf

Browse files
committed
Add work-around for Lumen
Fixes #124
1 parent 7881aa7 commit 9b899cf

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [4.0.8] - 25 Mar 2018
6+
### Added
7+
- work-around for missing `config_path()` function in Lumen.
8+
59
## [4.0.7] - 25 Mar 2018
610
### Added
711
- optional dedicated cache store.

src/Providers/GeocoderService.php

+25-7
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,40 @@ class GeocoderService extends ServiceProvider
2121

2222
public function boot()
2323
{
24-
$configPath = __DIR__ . '/../../config/geocoder.php';
25-
$this->publishes([$configPath => config_path('geocoder.php')], 'config');
26-
$this->mergeConfigFrom($configPath, 'geocoder');
27-
$this->app->singleton('geocoder', function () {
24+
$configPath = __DIR__ . "/../../config/geocoder.php";
25+
$this->publishes(
26+
[$configPath => $this->configPath("geocoder.php")],
27+
"config"
28+
);
29+
$this->mergeConfigFrom($configPath, "geocoder");
30+
$this->app->singleton("geocoder", function () {
2831
return (new ProviderAndDumperAggregator)
29-
->registerProvidersFromConfig(collect(config('geocoder.providers')));
32+
->registerProvidersFromConfig(collect(config("geocoder.providers")));
3033
});
3134
}
3235

3336
public function register()
3437
{
35-
$this->app->alias('Geocoder', Geocoder::class);
38+
$this->app->alias("Geocoder", Geocoder::class);
3639
}
3740

3841
public function provides() : array
3942
{
40-
return ['geocoder'];
43+
return ["geocoder"];
44+
}
45+
46+
protected function configPath(string $path = "") : string
47+
{
48+
if (function_exists("config_path")) {
49+
return config_path($path);
50+
}
51+
52+
$pathParts = [
53+
app()->basePath(),
54+
"config",
55+
trim($path, "/"),
56+
];
57+
58+
return implode("/", $pathParts);
4159
}
4260
}

0 commit comments

Comments
 (0)