Skip to content

Commit

Permalink
Fix support Lumen
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperl22 committed Oct 12, 2018
1 parent b0738b1 commit 32be149
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 32 deletions.
58 changes: 29 additions & 29 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
}
}
21 changes: 18 additions & 3 deletions src/DB2ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
}

/**
Expand Down Expand Up @@ -85,6 +86,20 @@ public function register()
}
}

/**
* 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.
*
Expand Down
File renamed without changes.

0 comments on commit 32be149

Please sign in to comment.