Skip to content

Commit e70d3a9

Browse files
authored
Api CLI (#1)
CLI commands for Client Co-authored-by: uanabitarte <uanabitarte@localhost>
1 parent 4fda872 commit e70d3a9

30 files changed

+5415
-0
lines changed

.env

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# In all environments, the following files are loaded if they exist,
2+
# the latter taking precedence over the former:
3+
#
4+
# * .env contains default values for the environment variables needed by the app
5+
# * .env.local uncommitted file with local overrides
6+
# * .env.$APP_ENV committed environment-specific defaults
7+
# * .env.$APP_ENV.local uncommitted environment-specific overrides
8+
#
9+
# Real environment variables win over .env files.
10+
#
11+
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
12+
#
13+
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
14+
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
15+
16+
###> symfony/framework-bundle ###
17+
APP_ENV=dev
18+
APP_SECRET=707003b1c34b14928ba481fab1eba00c
19+
#TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
20+
#TRUSTED_HOSTS='^(localhost|example\.com)$'
21+
###< symfony/framework-bundle ###

.gitignore

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Symfony4 default gitignore #
2+
##############################
3+
4+
###> symfony/framework-bundle ###
5+
/.env.local
6+
/.env.local.php
7+
/.env.*.local
8+
/config/secrets/prod/prod.decrypt.private.php
9+
/public/bundles/
10+
/var/
11+
/vendor/
12+
###< symfony/framework-bundle ###
13+
14+
# OS generated files #
15+
######################
16+
/.buildpath
17+
/.project
18+
/.settings/
19+
20+
# CLI package #
21+
###############
22+
/elkarbackup-api-cli.phar

bin/console

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
use App\Kernel;
5+
use Symfony\Bundle\FrameworkBundle\Console\Application;
6+
use Symfony\Component\Console\Input\ArgvInput;
7+
use Symfony\Component\ErrorHandler\Debug;
8+
9+
if (!in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
10+
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
11+
}
12+
13+
set_time_limit(0);
14+
15+
require dirname(__DIR__).'/vendor/autoload.php';
16+
17+
if (!class_exists(Application::class)) {
18+
throw new LogicException('You need to add "symfony/framework-bundle" as a Composer dependency.');
19+
}
20+
21+
$input = new ArgvInput();
22+
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
23+
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
24+
}
25+
26+
if ($input->hasParameterOption('--no-debug', true)) {
27+
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
28+
}
29+
30+
require dirname(__DIR__).'/config/bootstrap.php';
31+
32+
if ($_SERVER['APP_DEBUG']) {
33+
umask(0000);
34+
35+
if (class_exists(Debug::class)) {
36+
Debug::enable();
37+
}
38+
}
39+
40+
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
41+
$application = new Application($kernel);
42+
$application->run($input);

bin/elkarbackup-api-cli

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
require __DIR__.'/../vendor/autoload.php';
5+
6+
use App\Command;
7+
use Symfony\Component\Console\Application;
8+
9+
$application = new Application('elkarbackup-api-cli', '@package_version@');
10+
$application->add(new Command\DeleteClientCommand());
11+
$application->add(new Command\GetClientsCommand());
12+
$application->add(new Command\GetClientCommand());
13+
$application->add(new Command\PostClientCommand());
14+
$application->add(new Command\PostClientFromFileCommand());
15+
$application->add(new Command\UpdateClientCommand());
16+
$application->add(new Command\UpdateClientFromFileCommand());
17+
$application->run();

box.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"main": "bin/elkarbackup-api-cli",
3+
"output": "elkarbackup-api-cli.phar"
4+
}

build.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
vendor/bin/box compile

composer.json

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"type": "project",
3+
"license": "proprietary",
4+
"require": {
5+
"php": ">=7.1.3",
6+
"ext-ctype": "*",
7+
"ext-iconv": "*",
8+
"jetbrains/phpstorm-stubs": "dev-master",
9+
"symfony/console": "4.4.*",
10+
"symfony/dotenv": "4.4.*",
11+
"symfony/flex": "^1.3.1",
12+
"symfony/framework-bundle": "4.4.*",
13+
"symfony/http-client": "4.4.*",
14+
"symfony/yaml": "4.4.*"
15+
},
16+
"require-dev": {
17+
"bamarni/composer-bin-plugin": "^1.4",
18+
"humbug/box": "^3.12"
19+
},
20+
"config": {
21+
"preferred-install": {
22+
"*": "dist"
23+
},
24+
"sort-packages": true
25+
},
26+
"autoload": {
27+
"psr-4": {
28+
"App\\": "src/"
29+
}
30+
},
31+
"autoload-dev": {
32+
"psr-4": {
33+
"App\\Tests\\": "tests/"
34+
}
35+
},
36+
"replace": {
37+
"paragonie/random_compat": "2.*",
38+
"symfony/polyfill-ctype": "*",
39+
"symfony/polyfill-iconv": "*",
40+
"symfony/polyfill-php71": "*",
41+
"symfony/polyfill-php70": "*",
42+
"symfony/polyfill-php56": "*"
43+
},
44+
"scripts": {
45+
"auto-scripts": {
46+
"cache:clear": "symfony-cmd",
47+
"assets:install %PUBLIC_DIR%": "symfony-cmd"
48+
},
49+
"post-install-cmd": [
50+
"@auto-scripts"
51+
],
52+
"post-update-cmd": [
53+
"@auto-scripts"
54+
]
55+
},
56+
"conflict": {
57+
"symfony/symfony": "*"
58+
},
59+
"extra": {
60+
"symfony": {
61+
"allow-contrib": false,
62+
"require": "4.4.*"
63+
}
64+
}
65+
}

0 commit comments

Comments
 (0)