Fix support Lumen

This commit is contained in:
Maxime Rault 2018-10-12 11:50:35 +02:00
parent b0738b17a2
commit 32be149f95
3 changed files with 47 additions and 32 deletions

View File

@ -1,36 +1,36 @@
{
"name": "cooperl/laravel-db2",
"description": "laravel-db2 is a simple DB2 service provider for Laravel. It provides DB2 Connection by extending the Illuminate Database component of the laravel framework.",
"keywords": [
"laravel",
"DB2",
"Database",
"PDO",
"ODBC"
],
"license": "MIT",
"authors": [
"name": "cooperl/laravel-db2",
"description": "laravel-db2 is a simple DB2 service provider for Laravel. It provides DB2 Connection by extending the Illuminate Database component of the laravel framework.",
"keywords": [
"laravel",
"DB2",
"Database",
"PDO",
"ODBC"
],
"license": "MIT",
"authors": [
{
"name": "Maxime Rault",
"role": "Developer"
"name": "Maxime Rault",
"role": "Developer"
}
],
"require": {
"php": ">=7.1.3",
"illuminate/database": "5.7.*"
},
"require-dev": {
},
"autoload": {
],
"require": {
"php": ">=7.1.3",
"illuminate/database": "5.7.*"
},
"require-dev": {
},
"autoload": {
"psr-4": {
"Cooperl\\Database\\DB2\\": "src/"
"Cooperl\\Database\\DB2\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"Cooperl\\Database\\DB2\\DB2ServiceProvider"
]
},
"extra": {
"laravel": {
"providers": [
"Cooperl\\Database\\DB2\\DB2ServiceProvider"
]
}
}
}
}

View File

@ -2,6 +2,8 @@
namespace Cooperl\Database\DB2;
use Illuminate\Foundation\Application as LaravelApplication;
use Laravel\Lumen\Application as LumenApplication;
use Cooperl\Database\DB2\Connectors\ODBCConnector;
use Cooperl\Database\DB2\Connectors\IBMConnector;
use Cooperl\Database\DB2\Connectors\ODBCZOSConnector;
@ -28,9 +30,8 @@ class DB2ServiceProvider extends ServiceProvider
*/
public function boot()
{
$this->publishes([
__DIR__ . '/config/config.php' => config_path('db2.php'),
]);
$configPath = __DIR__ . '/config/db2.php';
$this->publishes([$configPath => $this->getConfigPath()], 'config');
}
/**
@ -85,6 +86,20 @@ class DB2ServiceProvider extends ServiceProvider
}
}
/**
* Get the config path
*
* @return string
*/
protected function getConfigPath()
{
if ($this->app instanceof LaravelApplication) {
return config_path('db2.php');
} elseif ($this->app instanceof LumenApplication) {
return base_path('config/db2.php');
}
}
/**
* Get the services provided by the provider.
*