protected function execute(InputInterface $input, OutputInterface $output) { if (!file_exists('bootstrap.php')) { throw new \Exception("Run this script in the application root directory"); } \Kwf_Setup::setUp(); if (file_exists('setup/initial/dump.sql')) { unlink('setup/initial/dump.sql'); } if (file_exists('setup/initial/uploads')) { foreach (glob('setup/initial/uploads/*') as $f) { unlink($f); } } if ($input->getOption('include-initial-dump')) { $output->writeln("checking for pending updates..."); $pendingUpdatesCount = \Kwf_Util_Update_Helper::countPendingUpdates(); if ($pendingUpdatesCount) { throw new \Exception("{$pendingUpdatesCount} Updates have not been executed. Run update first."); } $output->writeln("creating database dump..."); $dump = DbDump::dump(); if (!file_exists('setup/initial')) { mkdir('setup/initial', 0777, true); $ignore = ""; if (file_exists('setup/.gitignore')) { $ignore = file_get_contents('setup/.gitignore'); } if (!preg_match('#^initial$#m', $ignore)) { $ignore = rtrim($ignore); if ($ignore) { $ignore .= "\n"; } $ignore .= "initial\n"; } file_put_contents('setup/.gitignore', $ignore); } file_put_contents('setup/initial/dump.sql', $dump); $output->writeln("copying uploads..."); if (!file_exists('setup/initial/uploads')) { mkdir('setup/initial/uploads'); } $model = \Kwf_Model_Abstract::getInstance('Kwf_Uploads_Model'); $select = new \Kwf_Model_Select(); $it = new \Kwf_Model_Iterator_Packages(new \Kwf_Model_Iterator_Rows($model, $select)); foreach ($it as $row) { $fileSource = $row->getFileSource(); copy($fileSource, 'setup/initial/uploads/' . basename($fileSource)); } } $excludes = ExcludeFinder::findExcludes('.'); $excludeArgs = ''; foreach ($excludes as $i) { $excludeArgs .= " -x " . escapeshellarg('./' . $i . '*'); } $cmd = "zip deploy.zip . --quiet -r {$excludeArgs}"; $output->writeln("creating deploy.zip archive..."); $this->_systemCheckRet($cmd, $input, $output); $output->writeln("deploy.zip successfully created."); }
protected function execute(InputInterface $input, OutputInterface $output) { \Kwf_Setup::setUp(); $dbConfig = \Kwf_Registry::get('dao')->getDbConfig(); $cacheTables = \Kwf_Util_ClearCache::getInstance()->getDbCacheTables(); $dumpCmd = "mysqldump"; $dumpCmd .= " --host=" . escapeshellarg($dbConfig['host']); $dumpCmd .= " --user="******" --password="******" --ignore-table=" . escapeshellarg($dbConfig['dbname'] . '.' . $t); } $cmd .= " {$dbConfig['dbname']}"; passthru($cmd, $ret); if ($ret) { return $ret; } foreach ($cacheTables as $t) { $cmd = $dumpCmd; $cmd .= " --no-data " . escapeshellarg($dbConfig['dbname']) . " " . escapeshellarg($t); passthru($cmd, $ret); if ($ret) { return $ret; } } return 0; }
protected function execute(InputInterface $input, OutputInterface $output) { if (!file_exists($_SERVER['HOME'] . '/.aws/config')) { throw new \Exception("Can't get aws config, set up eb cli first"); } $awsConfig = parse_ini_file($_SERVER['HOME'] . '/.aws/config', true); $awsConfig = array('key' => $awsConfig['profile eb-cli']['aws_access_key_id'], 'secret' => $awsConfig['profile eb-cli']['aws_secret_access_key']); $s3 = new \Kwf_Util_Aws_S3($awsConfig); \Kwf_Setup::setUp(); $prodSection = $input->getOption('server'); $prodConfig = \Kwf_Config_Web::getInstance($prodSection); $bucket = $prodConfig->aws->uploadsBucket; if (!$bucket) { throw new \Exception("No aws.uploadBucket configured for '{$prodSection}'"); } $model = \Kwf_Model_Abstract::getInstance('Kwf_Uploads_Model'); $select = new \Kwf_Model_Select(); $it = new \Kwf_Model_Iterator_Packages(new \Kwf_Model_Iterator_Rows($model, $select)); $it = new \Kwf_Iterator_ConsoleProgressBar($it); foreach ($it as $row) { $file = $row->getFileSource(); if (file_exists($file)) { if ($s3->if_object_exists($bucket, $row->id)) { echo "already existing: {$row->id}\n"; } else { echo "uploading: {$row->id}"; $contents = file_get_contents($file); $r = $s3->create_object($bucket, $row->id, array('body' => $contents, 'length' => strlen($contents), 'contentType' => $row->mime_type)); if (!$r->isOk()) { throw new \Exception($r->body); } echo " OK\n"; } } } }
<?php chdir(dirname(__FILE__) . '/tests'); set_include_path('.' . PATH_SEPARATOR . realpath(getcwd() . '/..')); define('VENDOR_PATH', '../vendor'); require 'Kwf/Setup.php'; Kwf_Setup::setUp(); if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] == '/') { echo Kwf_Registry::get('config')->application->kwf->name . ' ' . Kwf_Registry::get('config')->application->kwf->version; exit; } $front = Kwf_Controller_Front::getInstance(); $front->addControllerDirectory(KWF_PATH . '/tests', 'kwf_test'); $front->addControllerDirectory(KWF_PATH . '/tests/controller', 'tests_controller'); $router = $front->getRouter(); if ($router instanceof Kwf_Controller_Router) { //für selenium-tests von sachen die im kwf liegen $router->AddRoute('kwf_test', new Zend_Controller_Router_Route('/kwf/test/:controller/:action', array('module' => 'kwf_test', 'action' => 'index'))); $router->AddRoute('kwf_kwctest', new Zend_Controller_Router_Route_Regex('kwf/kwctest/([^/]+)/(.*)', array('module' => 'tests_controller', 'controller' => 'render-component', 'action' => 'index', 'url' => ''), array('root' => 1, 'url' => 2))); $router->AddRoute('kwf_test_componentedit', new Zend_Controller_Router_Route('/kwf/componentedittest/:root/:class/:componentController/:action', array('module' => 'component_test', 'controller' => 'component_test', 'action' => 'index'))); } $front->setBaseUrl(''); $response = $front->dispatch(); $response->sendResponse();
<?php define('KWF_PATH', 'vendor/koala-framework/koala-framework'); define('VENDOR_PATH', 'vendor'); require VENDOR_PATH . '/koala-framework/koala-framework/Kwf/Setup.php'; Kwf_Setup::setUp('Kwf_Modernizr_Config');