Skip to content

Commit e355463

Browse files
committed
add laravel providers
1 parent 0c30b14 commit e355463

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Diff for: src/Providers/ServiceProvider.php

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Reactphp\Framework\Orm\Providers;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
use Illuminate\Database\Connection;
7+
use Reactphp\Framework\Orm\AsyncMysqlConnection;
8+
use Reactphp\Framework\Orm\AsyncMysqlConnector;
9+
10+
class AppServiceProvider extends ServiceProvider
11+
{
12+
/**
13+
* Bootstrap any application services.
14+
*/
15+
public function boot(): void
16+
{
17+
//
18+
}
19+
20+
/**
21+
* Register any application services.
22+
*/
23+
public function register(): void
24+
{
25+
Connection::resolverFor('async-mysql', function ($connection, $database, $prefix, $config) {
26+
return new AsyncMysqlConnection($connection, $database, $prefix, $config);
27+
});
28+
$this->app->bind(AsyncMysqlConnector::class, fn() => new AsyncMysqlConnector);
29+
$this->app->alias(AsyncMysqlConnector::class, 'db.connector.async-mysql');
30+
}
31+
}

0 commit comments

Comments
 (0)