Skip to content

Commit 366d738

Browse files
committed
Add a selfoss CLI tool
This introduces two commands for dumping and loading the database contents: - `php bin/selfoss db:export path.json` - `php bin/selfoss db:import path.json` Those are useful for testing, as well as for moving data from one database backend to another.
1 parent 1ccb803 commit 366d738

14 files changed

+414
-154
lines changed

.php-cs-fixer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
->exclude('assets')
55
->exclude('utils')
66
->in(__DIR__)
7-
->name('*.phtml');
7+
->name('*.phtml')
8+
->name('selfoss');
89

910
$rules = [
1011
'@Symfony' => true,

bin/selfoss

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
require __DIR__ . '/../src/common.php';
5+
6+
use Commands\Database\ExportCommand as DatabaseExportCommand;
7+
use Commands\Database\ImportCommand as DatabaseImportCommand;
8+
use Monolog\Handler\StreamHandler;
9+
use Symfony\Component\Console\Application;
10+
11+
$application = new Application();
12+
13+
$log->popHandler();
14+
$handler = new StreamHandler('php://stderr');
15+
$log->pushHandler($handler);
16+
17+
$application->add($dice->create(DatabaseExportCommand::class));
18+
$application->add($dice->create(DatabaseImportCommand::class));
19+
20+
$application->run();

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"php-http/guzzle6-adapter": "^1.0",
2323
"simplepie/simplepie": "^1.3",
2424
"smottt/wideimage": "^1.1",
25+
"symfony/console": "^3.4",
2526
"violet/streaming-json-encoder": "^1.1",
2627
"willwashburn/phpamo": "^1.0"
2728
},
@@ -39,6 +40,7 @@
3940
],
4041
"autoload": {
4142
"psr-4": {
43+
"Commands\\": "src/Commands/",
4244
"controllers\\": "src/controllers/",
4345
"daos\\": "src/daos/",
4446
"helpers\\": "src/helpers/",

composer.lock

Lines changed: 153 additions & 153 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)