Skip to content

Commit 88ace14

Browse files
committed
Merge pull request #5 from igormukhingmailcom/refactoring
Refactored: Code and dependencies; tests added
2 parents e185193 + a04c322 commit 88ace14

19 files changed

+577
-875
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_style = space
7+
indent_size = 4
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.yml]
12+
indent_style = space
13+
indent_size = 2

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
*~
22
vendor/
3+
composer.lock
4+
phpunit.xml

README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
11
schema-loader
22
=============
33

4-
Load database schema from an XML file
4+
Load database schema from an XML file.
55

6-
Example usage:
6+
## Usage
7+
8+
You can load schema to database by PDO url:
9+
10+
```bash
11+
./bin/dbtk-schema-loader schema:load example/schema.xml mysql://username:password@localhost/database_name
712
```
8-
bin/dbtk-schema-loader schema:load example/example.xml mysql://username:password@localhost/test
13+
14+
or by database name:
15+
16+
```bash
17+
./bin/dbtk-schema-loader schema:load example/schema.xml database_name
918
```
19+
20+
In this case you must have a `database_name.conf` file at `/share/config/database/` as described at [database-manager's documentation](https://github.com/linkorb/database-manager#database-configuration-files).
21+
22+
## License
23+
Please refer to the included LICENSE file
24+
25+
## Brought to you by the LinkORB Engineering team
26+
27+
<img src="http://www.linkorb.com/d/meta/tier1/images/linkorbengineering-logo.png" width="200px" /><br />
28+
Check out our other projects at [engineering.linkorb.com](http://engineering.linkorb.com).
29+
30+
Btw, we're hiring!

bin/dbtk-schema-loader

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
#!/usr/bin/env php
22
<?php
33

4-
$baseDir = __DIR__ . '/..';
5-
if (!file_exists($baseDir . '/vendor')) {
6-
$baseDir = __DIR__ . '/../../../..';
4+
$filename = __DIR__ . '/../vendor/autoload.php';
5+
if (!file_exists($filename)) {
6+
$filename = __DIR__ . '/../../../autoload.php';
77
}
88

9-
if (!file_exists($baseDir . '/vendor/autoload.php')) {
9+
if (!file_exists($filename)) {
1010
die(
11-
'File not found: ' . $baseDir . '/vendor/autoload.php' . PHP_EOL .
1211
'You must set up the project dependencies, run the following commands:' . PHP_EOL .
1312
'curl -s http://getcomposer.org/installer | php' . PHP_EOL .
1413
'php composer.phar install' . PHP_EOL
1514
);
1615
}
17-
$loader = require $baseDir . '/vendor/autoload.php';
18-
$cli = new crodas\cli\Cli;
19-
$cli->addDirectory(__DIR__ . "/../src/Command");
20-
$cli->main();
16+
17+
$loader = require $filename;
18+
19+
use Symfony\Component\Console\Application;
20+
21+
$application = new Application('DBTK Schema Loader', '1.1.0');
22+
$application->setCatchExceptions(true);
23+
$application->add(new \DbTk\SchemaLoader\Command\LoadCommand());
24+
$application->run();

composer.json

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
{
22
"name": "dbtk/schema-loader",
33
"description": "Load Database schema from XML",
4-
"authors": [
5-
{
6-
"name": "Joost Faassen",
7-
"email": "j.faassen@linkorb.com"
8-
}
9-
],
4+
"authors": [{
5+
"name": "Joost Faassen",
6+
"email": "j.faassen@linkorb.com"
7+
}],
108
"bin": ["bin/dbtk-schema-loader"],
119
"minimum-stability": "stable",
1210
"require": {
13-
"doctrine/dbal": "*",
14-
"crodas/cli": "*"
11+
"doctrine/dbal": "~2.5"
12+
},
13+
"require-dev": {
14+
"phpunit/phpunit": "~4.6"
15+
},
16+
"autoload": {
17+
"psr-4": {
18+
"DbTk\\SchemaLoader\\": "src/"
19+
}
20+
},
21+
"autoload-dev": {
22+
"psr-4": {
23+
"DbTk\\SchemaLoader\\Tests\\": "tests/"
24+
}
1525
}
1626
}

0 commit comments

Comments
 (0)