Skip to content

Commit

Permalink
some smaller enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
stmh committed Sep 11, 2018
1 parent 80f4c4b commit 9535c4e
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This file is a "template" of which env vars need to be defined for your application
# Copy this file to .env file for development, create environment variables when deploying to production
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
3 changes: 3 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This file is a "template" of which env vars need to be defined for your application
# Copy this file to .env file for development, create environment variables when deploying to production
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
33 changes: 28 additions & 5 deletions bin/pha
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
#!/usr/bin/env php
<?php
// application.php

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

use Phabalicious\AppKernel;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Output\ConsoleOutput;

$kernel = new AppKernel();
set_time_limit(0);

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

if (!isset($_SERVER['APP_ENV'])) {
if (!class_exists(Dotenv::class)) {
throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
}
(new Dotenv())->load(__DIR__.'/../.env');
}

$input = new ArgvInput();
$env = $input->getParameterOption(['--env', '-e'], $_SERVER['APP_ENV'] ?? 'dev', true);
$debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env)) && !$input->hasParameterOption('--no-debug', true);

if ($debug) {
umask(0000);

if (class_exists(Debug::class)) {
Debug::enable();
}
}

$kernel = new AppKernel($env, $debug);
$kernel->boot();
$container = $kernel->getContainer();

Expand All @@ -17,4 +40,4 @@ $application = $container->get(Application::class);
$application->setVersion('3.0.0');
$application->setName('phabalicious');

$application->run(null, $container->get(ConsoleOutput::class));
$application->run($input, $container->get(ConsoleOutput::class));
11 changes: 9 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"symfony/yaml": "^4.1",
"wikimedia/composer-merge-plugin": "^1.4",
"composer/semver": "^1.4",
"symfony/process": "^4.1"
"symfony/process": "^4.1",
"symfony/flex": "^1.1",
"symfony/dotenv": "^4.1"
},
"require-dev": {
"symfony/phpunit-bridge": "^4.1",
Expand All @@ -26,5 +28,10 @@
"name": "Stephan Maximilian Huber",
"email": "[email protected]"
}
]
],
"scripts": {
"auto-scripts": {

}
}
}
106 changes: 105 additions & 1 deletion composer.lock

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

7 changes: 1 addition & 6 deletions src/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@

class AppKernel extends Kernel
{
public function __construct()
{
// these values allows container rebuild when config changes
parent::__construct('dev', true);
}
/**
* @return BundleInterface[]
*/
Expand All @@ -41,7 +36,7 @@ public function getLogDir(): string
return sys_get_temp_dir() . '/phabalicious' . md5(self::class);
}

protected function build(ContainerBuilder $containerBuilder): void
protected function build(ContainerBuilder $containerBuilder)
{
$containerBuilder->addCompilerPass(new CollectCommandsToApplicationCompilerPass());
$containerBuilder->addCompilerPass(new CollectMethodsToFactoryCompilerPass());
Expand Down
14 changes: 11 additions & 3 deletions src/Method/ScriptMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,20 @@ public function runScript(HostConfig $host_config, TaskContext $context)
$variables = $context->get('variables', []);
$callbacks = $context->get('callbacks', []);
$environment = $context->get('environment', []);
$root_folder = isset($host_config['siteFolder']) ? $host_config['siteFolder'] ? $host_config['rootFolder'] : '.';
$root_folder = isset($host_config['siteFolder'])
? $host_config['siteFolder']
: isset($host_config['rootFolder'])
? $host_config['rootFolder']
: '.';

if (!empty($host_config['environment'])) {
$environment = Utilities::mergeData($environment, $host_config['environment']);
}
$variables['host'] = $host_config->raw();
$variables['settings'] = $context->getConfigurationService()->getAllSettings(['hosts', 'dockerHosts']);
$variables = [
'variables' => $variables,
'host' => $host_config->raw(),
'settings' => $context->getConfigurationService()->getAllSettings(['hosts', 'dockerHosts']),
];

$replacements = Utilities::expandVariables($variables);
$commands = Utilities::expandStrings($commands, $replacements);
Expand All @@ -63,6 +70,7 @@ private function runScriptImpl(
array $callbacks = [],
array $environment = [],
array $replacements = []
)
{
}

Expand Down

0 comments on commit 9535c4e

Please sign in to comment.