Leadtech/BootFramework

View on GitHub
examples/console/hello_world/bin/console_no_cache

Summary

Maintainability
Test Coverage
#!/usr/bin/env php
<?php
// Autoload packages
require_once __DIR__ . '/../../../../vendor/autoload.php';

// Alias symfony console application
use Symfony\Component\Console\Application as ConsoleApplication;
use Symfony\Component\ClassLoader\Psr4ClassLoader;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputOption;
use Boot\Boot;

// Get environment
$input = new ArgvInput();
$env = $input->getParameterOption(array('--env', '-e'), Boot::DEVELOPMENT);

// Register autoloader (in your own product use the autoloader that ships with composer, this is just for demo purposes)
$loader = new Psr4ClassLoader();
$loader->addPrefix('HelloWorld\\', __DIR__ . '/../src/HelloWorld');
$loader->register();

// Build application
$rootDir = realpath(__DIR__ . '/..');
$app = (new \Boot\Console\ConsoleBuilder($rootDir))
    ->appName('SimpleConsoleApplication')
    ->appVersion('1.0.0')
    ->environment($env)
    ->configDir('resources/config')
    ->parameter('project_dir', $rootDir)
    ->build()
;

// Run the application
$app->run();