Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Commit

Permalink
Commands and factories moved to their own packages
Browse files Browse the repository at this point in the history
  • Loading branch information
mkorkmaz committed Jul 22, 2017
1 parent d4b2f1f commit b0f66fb
Show file tree
Hide file tree
Showing 26 changed files with 171 additions and 452 deletions.
12 changes: 1 addition & 11 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
#!/usr/bin/env php
<?php
declare(strict_types=1);

chdir(dirname(__DIR__));

require_once './vendor/autoload.php';

use Selami\Console\ApplicationFactory;

$container = require './config/container.php';

$cli = ApplicationFactory::makeApplication($container);
$cli->run();
include __DIR__.'/console.php';
8 changes: 8 additions & 0 deletions bin/console.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
declare(strict_types=1);
chdir(dirname(__DIR__));
require_once './vendor/autoload.php';
use Selami\Console\ApplicationFactory;
$container = require './config/container.php';
$cli = ApplicationFactory::makeApplication($container);
$cli->run();
14 changes: 6 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"require": {
"php": "^7.1",
"selami/stdlib": "^1.3",
"selami/foundation": "~0.10",
"selami/console": "~0.2",
"symfony/process": "~3.3",
"selami/foundation": "^0.10",
"selami/commands": "dev-master",
"selami/zend-servicemanager-factories": "^0.1",
"symfony/http-foundation": "~3.3"
},
"require-dev": {
Expand All @@ -29,11 +29,7 @@
"minimum-stability": "stable",
"autoload": {
"psr-4": {
"SelamiApp\\Controller\\": "src/apps/www/controllers",
"SelamiApp\\Command\\": "src/commands",
"SelamiApp\\Extension\\": "src/extensions",
"SelamiApp\\Factories\\": "src/factories"

"SelamiApp\\Controller\\": "src/apps/www/controllers"
}
},
"scripts": {
Expand All @@ -42,6 +38,8 @@
],
"post-create-project-cmd": [
"cp config/autoload/local.php.dist config/autoload/local.php",
"cp config/autoload/view.local.php.dist config/autoload/view.local.php",
"cp config/autoload/commands.local.php.dist config/autoload/commands.local.php",
"composer dump-autoload -o"
]
}
Expand Down
126 changes: 104 additions & 22 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions config/autoload/commands.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

return [
'commands' => [
SelamiApp\Command\Info::class,
SelamiApp\Command\Server\ServerRun::class,
Selami\Command\Info::class,
Selami\Command\Server\ServerRun::class,
// Cache Commands
SelamiApp\Command\Cache\ClearAll::class,
SelamiApp\Command\Cache\ClearConfig::class,
SelamiApp\Command\Cache\ClearRouteDispatcherData::class
Selami\Command\Cache\ClearAll::class,
Selami\Command\Cache\ClearConfig::class,
Selami\Command\Cache\ClearRouteDispatcherData::class,
Selami\Command\Cache\ClearViewData::class
]
];
7 changes: 7 additions & 0 deletions config/autoload/commands.local.php.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
declare(strict_types=1);

return [
'commands' => [
]
];
5 changes: 2 additions & 3 deletions config/autoload/dependencies.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
declare(strict_types=1);

use Psr\Http\Message\ServerRequestInterface;
use Psr\Container\ContainerInterface;
use Symfony\Component\HttpFoundation\Session\Session;
use Selami\Router;
use Selami\View\ViewInterface as SelamiView;
use Twig_Environment as TwigEnvironment;
use Selami\Foundation\App as SelamiApplication;
use SelamiApp\Factories;
use Selami\Factories;
return [
'dependencies' => [
'factories' => [
Expand All @@ -17,7 +16,7 @@
Session::class => Factories\SymfonySessionFactory::class,
Router::class => Factories\RouterFactory::class,
TwigEnvironment::class => Factories\TwigFactory::class,
SelamiView::class => Factories\SelamiViewFactory::class
SelamiView::class => Factories\SelamiViewTwigFactory::class
],
]
];
12 changes: 12 additions & 0 deletions config/autoload/view.local.php.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);

return [
'view' => [
'type' => 'twig',
'twig' => [
'cache' => './cache/twig',
'debug' => false,
]
]
];
5 changes: 3 additions & 2 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
foreach (Glob::glob(__DIR__ . '/autoload/{{,*.}global,{,*.}local}.php', Glob::GLOB_BRACE) as $file) {
$config = ArrayUtils::merge($config, include $file);
}

if (defined('RUNTIME_LANG')) {
$config = ArrayUtils::merge($config, include __DIR__ . '/lang/' . RUNTIME_LANG . '.php');
$config['view'] = ArrayUtils::merge($config['view'], include __DIR__ . '/lang/' . RUNTIME_LANG . '.php');
}

if (isset($config['config_cache_enabled']) && $config['config_cache_enabled'] === true) {
file_put_contents($cachedConfigFile, json_encode($config));
}
}

return $config;
8 changes: 5 additions & 3 deletions config/container.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
$config = include __DIR__ . '/config.php';

$globals = include __DIR__. '/globals.php';

$container = new ServiceManager($config['dependencies']);

if (PHP_SAPI !== 'cli') {
$config['app']['base_url'] = BaseUrlExtractor::getBaseUrl($_SERVER);
}
$container = new ServiceManager($config['dependencies']);
if (isset($routes)) {
$container->setService('routes', $routes);
}


$container->setService('config', $config);
$container->setService('globals', $globals);
$container->setService('commands', $config['commands']);
Expand Down
Loading

0 comments on commit b0f66fb

Please sign in to comment.