1 | <?php |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Gewaer\Providers; |
||
6 | |||
7 | use function Gewaer\Core\envValue; |
||
8 | use Phalcon\Db\Adapter\Pdo\Mysql; |
||
9 | use Phalcon\Di\ServiceProviderInterface; |
||
10 | use Phalcon\DiInterface; |
||
11 | |||
12 | class DatabaseProvider implements ServiceProviderInterface |
||
13 | { |
||
14 | /** |
||
15 | * @param DiInterface $container |
||
16 | */ |
||
17 | 17 | public function register(DiInterface $container) |
|
18 | { |
||
19 | 17 | $container->setShared( |
|
20 | 17 | 'db', |
|
21 | function () { |
||
22 | $options = [ |
||
23 | 17 | 'host' => envValue('DATA_API_MYSQL_HOST', 'localhost'), |
|
24 | 17 | 'username' => envValue('DATA_API_MYSQL_USER', 'nanobox'), |
|
25 | 17 | 'password' => envValue('DATA_API_MYSQL_PASS', ''), |
|
26 | 17 | 'dbname' => envValue('DATA_API_MYSQL_NAME', 'gonano'), |
|
27 | 17 | 'charset' => 'utf8', |
|
28 | ]; |
||
29 | |||
30 | 17 | $connection = new Mysql($options); |
|
31 | // Set everything to UTF8 |
||
32 | 17 | $connection->execute('SET NAMES utf8mb4', []); |
|
33 | |||
34 | 17 | return $connection; |
|
35 | 17 | } |
|
36 | ); |
||
37 | 17 | } |
|
38 | } |
||
39 |