Skip to content

Commit 941bdd4

Browse files
author
esazykin
committed
first commit
0 parents  commit 941bdd4

File tree

12 files changed

+2220
-0
lines changed

12 files changed

+2220
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/vendor
2+
/.idea
3+
composer.lock
4+
tests/coverage

composer.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "esazykin/laravel-clickhouse",
3+
"type": "library",
4+
"license": "MIT",
5+
"require": {
6+
"php": ">=7.1",
7+
"laravel/framework": "5.5.*",
8+
"esazykin/clickhouse-builder": "^1.1"
9+
},
10+
"autoload": {
11+
"psr-4": {
12+
"Esazykin\\LaravelClickHouse\\": "src/"
13+
}
14+
},
15+
"autoload-dev": {
16+
"psr-4": {
17+
"Esazykin\\LaravelClickHouse\\Tests\\": "tests/"
18+
}
19+
},
20+
"scripts": {
21+
"test": "vendor/bin/phpunit --stop-on-failure tests/"
22+
},
23+
"require-dev": {
24+
"phpunit/phpunit": "^6.5",
25+
"mockery/mockery": "^1.0",
26+
"fzaninotto/faker": "^1.7"
27+
}
28+
}

phpunit.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false">
11+
<testsuites>
12+
<testsuite name="Unit">
13+
<directory suffix="Test.php">./tests/Unit</directory>
14+
</testsuite>
15+
</testsuites>
16+
<filter>
17+
<whitelist>
18+
<directory suffix=".php">src/Database/</directory>
19+
</whitelist>
20+
</filter>
21+
<logging>
22+
<log type="coverage-html" target="tests/coverage" charset="UTF-8" highlight="true"/>
23+
</logging>
24+
</phpunit>

src/ClickHouseServiceProvider.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Esazykin\LaravelClickHouse;
6+
7+
use Esazykin\LaravelClickHouse\Database\Connection;
8+
use Esazykin\LaravelClickHouse\Database\Eloquent\Model;
9+
use Illuminate\Database\DatabaseManager;
10+
use Illuminate\Support\ServiceProvider;
11+
12+
class ClickHouseServiceProvider extends ServiceProvider
13+
{
14+
public function boot(): void
15+
{
16+
/** @var DatabaseManager $db */
17+
$db = $this->app->get('db');
18+
19+
$db->extend('clickhouse', function ($config, $name) {
20+
$config['name'] = $name;
21+
22+
return new Connection($config);
23+
});
24+
25+
Model::setConnectionResolver($db);
26+
}
27+
}

src/Database/Connection.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Esazykin\LaravelClickHouse\Database;
6+
7+
use Esazykin\LaravelClickHouse\Database\Query\Builder;
8+
use Tinderbox\ClickhouseBuilder\Query\Grammar;
9+
10+
class Connection extends \Tinderbox\ClickhouseBuilder\Integrations\Laravel\Connection
11+
{
12+
public function query()
13+
{
14+
return new Builder($this, new Grammar());
15+
}
16+
}

0 commit comments

Comments
 (0)