Skip to content

Commit

Permalink
Small changes :^)
Browse files Browse the repository at this point in the history
  • Loading branch information
jesperbeisner committed Oct 13, 2022
1 parent 69d2bbf commit 6c424b4
Show file tree
Hide file tree
Showing 87 changed files with 1,145 additions and 1,194 deletions.
7 changes: 7 additions & 0 deletions .env.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

declare(strict_types=1);

return [
'APP_ENV' => 'dev',
];
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
/data/logs/*
!/data/logs/.gitkeep

/config/config.local.php
.env.local.php.dist
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ docker-compose exec php php bin/console.php app:database-fixture

```bash
# Create prod config and change needed values
cp ./config/config.local.php.dist ./config/config.local.php
cp ./.env.local.php.dist ./.env.local.php

# Docker
docker-compose -f docker-compose.prod.yml up -d --build
Expand Down
17 changes: 7 additions & 10 deletions bin/console.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
declare(strict_types=1);

use Jesperbeisner\Fwstats\Command\AbstractCommand;
use Jesperbeisner\Fwstats\Stdlib\ServiceContainer;
use Jesperbeisner\Fwstats\Stdlib\Container;

/** @var ServiceContainer $serviceContainer */
$serviceContainer = require __DIR__ . '/../bootstrap.php';
/** @var Container $container */
$container = require __DIR__ . '/../bootstrap.php';

/** @var mixed[] $config */
$config = $serviceContainer->get('config');

/** @var string[] $commandStrings */
$commandStrings = $config['commands'];
/** @var array<class-string<AbstractCommand>> $commands */
$commandStrings = require __DIR__ . '/../config/commands.php';

if (!isset($argv[1])) {
echo 'Available commands: ' . PHP_EOL . PHP_EOL;
Expand Down Expand Up @@ -41,13 +38,13 @@
exit(1);
}

if (!$serviceContainer->has($commandClass)) {
if (!$container->has($commandClass)) {
echo "Command '$commandClass' not found in the service container. Did you forget to register it?" . PHP_EOL;
exit(1);
}

/** @var AbstractCommand $command */
$command = $serviceContainer->get($commandClass);
$command = $container->get($commandClass);
$command->setArguments($argv);

exit($command->execute());
20 changes: 10 additions & 10 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

declare(strict_types=1);

use Jesperbeisner\Fwstats\Stdlib\ServiceContainer;
use Jesperbeisner\Fwstats\Stdlib\Config;
use Jesperbeisner\Fwstats\Stdlib\DotEnvPhpLoader;
use Jesperbeisner\Fwstats\Stdlib\Container;
use Jesperbeisner\Fwstats\Stdlib\Router;

require __DIR__ . '/vendor/autoload.php';

$config = require __DIR__ . '/config/config.php';
DotEnvPhpLoader::load([__DIR__ . '/.env.php', __DIR__ . '/.env.local.php']);

if (file_exists(__DIR__ . '/config/config.local.php')) {
$configLocal = require __DIR__ . '/config/config.local.php';
$config = array_merge($config, $configLocal);
}
$config = new Config(__DIR__ . '/config/config.php');
$router = new Router(__DIR__ . '/config/routes.php');

$serviceContainer = new ServiceContainer($config['services']);
$serviceContainer = new Container(__DIR__ . '/config/services.php');

$serviceContainer->set('config', $config);
$serviceContainer->set('appEnv', $config['app_env']);
$serviceContainer->set('rootDir', __DIR__);
$serviceContainer->set(Config::class, $config);
$serviceContainer->set(Router::class, $router);

return $serviceContainer;
6 changes: 2 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jesperbeisner/fwstats",
"description": "Statistics website for the world 'ActionFreewar' in the browser game freewar.de",
"description": "Statistics website for the worlds 'ActionFreewar' and 'ChaosFreewar' in the browser game 'freewar.de'.",
"type": "project",
"license": "MIT",
"authors": [
Expand All @@ -12,9 +12,7 @@
],
"require": {
"php": "^8.1",
"nikic/fast-route": "^1.3",
"psr/container": "^2.0",
"psr/log": "^3.0"
"nikic/fast-route": "^1.3"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.9",
Expand Down
Loading

0 comments on commit 6c424b4

Please sign in to comment.