Skip to content

Commit adff8e6

Browse files
committed
hyperf-mongodb
1 parent 4b4323f commit adff8e6

File tree

9 files changed

+1086
-0
lines changed

9 files changed

+1086
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
composer.phar
2+
/vendor/
3+
4+
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
5+
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
6+
composer.lock
7+
8+
.idea

composer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "adamchen1208/hyperf-mongodb",
3+
"license": "Apache-2.0",
4+
"authors": [
5+
{
6+
"name": "adamchen1208",
7+
"email": "adamchen1208@foxmail.com"
8+
}
9+
],
10+
"require": {
11+
"php": ">=7.2",
12+
"psr/container": "^1.0",
13+
"hyperf/pool": "~1.1.0",
14+
"hyperf/contract": "~1.1.0",
15+
"hyperf/utils": "~1.1.0"
16+
},
17+
"autoload": {
18+
"classmap": [
19+
],
20+
"psr-4": {
21+
"Hyperf\\Mongodb\\": "src"
22+
}
23+
},
24+
"extra": {
25+
"hyperf": {
26+
"config": "Hyperf\\Mongodb\\ConfigProvider"
27+
}
28+
}
29+
}

src/ConfigProvider.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: adamchen1208
5+
* Date: 2020/7/24
6+
* Time: 15:29
7+
*/
8+
9+
namespace Hyperf\Mongodb;
10+
11+
use Hyperf\Mongodb\Mongodb;
12+
13+
class ConfigProvider
14+
{
15+
public function __invoke(): array
16+
{
17+
return [
18+
'dependencies' => [
19+
Mongodb::class => Mongodb::class,
20+
],
21+
'commands' => [
22+
],
23+
'scan' => [
24+
'paths' => [
25+
__DIR__,
26+
],
27+
],
28+
'publish' => [
29+
[
30+
'id' => 'config',
31+
'description' => 'The config of mongodb client.',
32+
'source' => __DIR__ . '/../publish/mongodb.php',
33+
'destination' => BASE_PATH . '/config/autoload/mongodb.php',
34+
],
35+
],
36+
];
37+
}
38+
}

src/Exception/MongoDBException.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: adamchen1208
5+
* Date: 2020/7/24
6+
* Time: 15:25
7+
*/
8+
9+
namespace Hyperf\Mongodb\Exception;
10+
11+
class MongoDBException extends \Exception
12+
{
13+
/**
14+
* @param string $msg
15+
* @throws MongoDBException
16+
*/
17+
public static function managerError(string $msg)
18+
{
19+
throw new self($msg);
20+
}
21+
}

0 commit comments

Comments
 (0)