Skip to content

Commit c11c57c

Browse files
authored
Disable auto-discovery (#1)
1 parent 50b3e33 commit c11c57c

12 files changed

+58
-29
lines changed

.coveralls.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

README.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,29 @@ A tiny extension of `MySqlConnection` that manages **session** system variables
1313
composer require mpyw/laravel-mysql-system-variable-manager
1414
```
1515

16-
The default implementation is provided by the automatically-discovered service provider.
17-
1816
## Basic Usage
1917

18+
The default implementation is provided by `LaravelMySqlSystemVariableManagerServiceProvider`, however, **package discovery is not available**.
19+
Be careful that you MUST register it in **`config/app.php`** by yourself.
20+
21+
```php
22+
<?php
23+
24+
return [
25+
26+
/* ... */
27+
28+
'providers' => [
29+
/* ... */
30+
31+
Mpyw\LaravelMySqlSystemVariableManager\LaravelMySqlSystemVariableManagerServiceProvider::class,
32+
33+
/* ... */
34+
],
35+
36+
];
37+
```
38+
2039
```php
2140
<?php
2241

@@ -70,7 +89,7 @@ class DatabaseServiceProvider extends ServiceProvider
7089
namespace App\Database;
7190

7291
use Illuminate\Database\Connection as BaseMySqlConnection;
73-
use Mpyw\LaravelMysqlSystemVariableManager\ManagesSystemVariables;
92+
use Mpyw\LaravelMySqlSystemVariableManager\ManagesSystemVariables;
7493

7594
class MySqlConnection extends BaseMySqlConnection
7695
{

composer.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
"keywords": ["laravel", "illuminate", "mysql", "system", "variable"],
1313
"autoload": {
1414
"psr-4": {
15-
"Mpyw\\LaravelMysqlSystemVariableManager\\": "src/"
15+
"Mpyw\\LaravelMySqlSystemVariableManager\\": "src/"
1616
}
1717
},
1818
"autoload-dev": {
1919
"psr-4": {
20-
"Lampager\\Laravel\\Tests\\": "tests/"
20+
"Mpyw\\LaravelMySqlSystemVariableManager\\Tests\\": "tests/"
2121
}
2222
},
2323
"require": {
@@ -31,12 +31,5 @@
3131
"laravel/framework": "^6.0",
3232
"nilportugues/sql-query-formatter": "^1.2",
3333
"friendsofphp/php-cs-fixer": "^2.15"
34-
},
35-
"extra": {
36-
"laravel": {
37-
"providers": [
38-
"Mpyw\\LaravelMysqlSystemVariableManager\\LaravelMysqlSystemVariableManagerServiceProvider"
39-
]
40-
}
4134
}
4235
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Mpyw\LaravelMySqlSystemVariableManager;
4+
5+
use Illuminate\Database\Connection;
6+
use Illuminate\Support\ServiceProvider;
7+
8+
/**
9+
* Class LaravelMySqlSystemVariableManagerServiceProvider
10+
*/
11+
class LaravelMySqlSystemVariableManagerServiceProvider extends ServiceProvider
12+
{
13+
public function boot(): void
14+
{
15+
Connection::resolverFor('mysql', function (...$parameters) {
16+
return new MySqlConnection(...$parameters);
17+
});
18+
}
19+
}

src/LaravelMysqlSystemVariableManagerServiceProvider.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
22

3-
namespace Mpyw\LaravelMysqlSystemVariableManager;
3+
namespace Mpyw\LaravelMySqlSystemVariableManager;
44

55
use Illuminate\Database\Connection;
66
use Illuminate\Support\ServiceProvider;
77

88
/**
9-
* Class LaravelMysqlSystemVariableManagerServiceProvider
9+
* Class LaravelMySqlSystemVariableManagerServiceProvider
1010
*/
11-
class LaravelMysqlSystemVariableManagerServiceProvider extends ServiceProvider
11+
class LaravelMySqlSystemVariableManagerServiceProvider extends ServiceProvider
1212
{
1313
public function boot(): void
1414
{

src/ManagesSystemVariables.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Mpyw\LaravelMysqlSystemVariableManager;
3+
namespace Mpyw\LaravelMySqlSystemVariableManager;
44

55
/**
66
* Trait ManagesSystemVariables

src/MySqlConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Mpyw\LaravelMysqlSystemVariableManager;
3+
namespace Mpyw\LaravelMySqlSystemVariableManager;
44

55
use Illuminate\Database\MySqlConnection as BaseMySqlConnection;
66

src/PdoDecorator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Mpyw\LaravelMysqlSystemVariableManager;
3+
namespace Mpyw\LaravelMySqlSystemVariableManager;
44

55
use Closure;
66
use PDO;

src/SystemVariableAwareReconnector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Mpyw\LaravelMysqlSystemVariableManager;
3+
namespace Mpyw\LaravelMySqlSystemVariableManager;
44

55
use Illuminate\Database\ConnectionInterface;
66
use LogicException;
@@ -41,7 +41,7 @@ public function memoizeSystemVariables(array $values)
4141
}
4242

4343
/**
44-
* @param \Illuminate\Database\ConnectionInterface|\Mpyw\LaravelMysqlSystemVariableManager\ManagesSystemVariables $connection
44+
* @param \Illuminate\Database\ConnectionInterface|\Mpyw\LaravelMySqlSystemVariableManager\ManagesSystemVariables $connection
4545
* @return mixed
4646
*/
4747
public function __invoke(ConnectionInterface $connection)

tests/BasicVariableAssignmentTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

3-
namespace Lampager\Laravel\Tests;
3+
namespace Mpyw\LaravelMySqlSystemVariableManager\Tests;
44

5-
use Mpyw\LaravelMysqlSystemVariableManager\MySqlConnection;
5+
use Mpyw\LaravelMySqlSystemVariableManager\MySqlConnection;
66
use PDOException;
77

88
class BasicVariableAssignmentTest extends TestCase

0 commit comments

Comments
 (0)