Created
August 30, 2012 10:53
-
-
Save roderik/3526251 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
require 'vendor/autoload.php'; | |
use Symfony\Component\Console\Command\Command; | |
use Symfony\Component\Yaml\Dumper; | |
use Symfony\Component\Console\Input\InputArgument; | |
use Symfony\Component\Console\Input\InputInterface; | |
use Symfony\Component\Console\Input\InputOption; | |
use Symfony\Component\Console\Output\OutputInterface; | |
use Symfony\Component\Console\Application; | |
use Symfony\Component\Yaml\Yaml; | |
class ConfigCommand extends Command | |
{ | |
protected function configure() | |
{ | |
$this | |
->setName('config:parameters') | |
->setDescription('Configs the parameters.yml file') | |
->addArgument('project', InputArgument::REQUIRED, 'The project name') | |
->addArgument('basepath', InputArgument::OPTIONAL, 'The path of the projecht. Defaults to .', ".") | |
; | |
} | |
protected function execute(InputInterface $input, OutputInterface $output) | |
{ | |
$projectname = $input->getArgument('project'); | |
$basepath = $input->getArgument('basepath'); | |
$basepath = (empty($basepath) ? "." : $input->getArgument('basepath') ); | |
$ymlpath = $basepath . '/app/config/parameters.yml'; | |
$loader = Yaml::parse($ymlpath); | |
$params =& $loader["parameters"]; | |
$params["searchport"] = 9200; | |
$params["searchindexname"] = $projectname; | |
$params["sentry.dsn"] = "https://XXXXXXXX:XXXXXXXX@app.getsentry.com/XXXX"; | |
$params["cdnpath"] = ""; | |
$params["requiredlocales"] = "nl|fr|de|en"; | |
$params["defaultlocale"] = "nl"; | |
$params["websitetitle"] = ucfirst($projectname); | |
$dumper = new Dumper(); | |
$yaml = $dumper->dump($loader, 5); | |
file_put_contents($ymlpath, $yaml); | |
} | |
} | |
$application = new Application(); | |
$application->add(new ConfigParametersCommand); | |
$application->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment