public function down(IOStream $io) { $fileSystem = $this->application()->getFileSystem(); $path = $this->application()->storagePath() . '/framework/down.php'; $stub = realpath(__DIR__ . '/../Stubs/down.stub'); if ($fileSystem->copy($stub, $path)) { $io->writeln("Application is down in maintenance", 'yellow'); } else { $io->showErr("Unable to create {$path}."); } }
private function runClass($class) { if (!strContains('\\', $class)) { $namespacedClass = $this->namespace . '\\' . $class; } else { $namespacedClass = $class; } /** @var AbstractSeeder $seeder */ $seeder = new $namespacedClass($this->application()->getMapper()); $seeder->run(); $this->io->writeln("Seeding of {$class} completed Successfully", 'green'); }
private function getRealFolder($appFolder, $fileType, IOStream $io) { $return = ['folder' => $appFolder . DIRECTORY_SEPARATOR . ucfirst($fileType) . 's', 'namespace' => "App\\" . ucfirst($fileType) . 's']; if (!is_dir($appFolder)) { $return['folder'] = $io->ask("App folder missing! Please Specify the Folder to create the file in:"); if (!is_dir($appFolder)) { throw new \InvalidArgumentException("Directory {$appFolder} doesn't exist."); } $return['namespace'] = $io->ask("Please provide namespace for given folder"); } return $return; }
public function execute(IOStream $io) { $command = $this->input('commandName'); if ($command) { /** @var Command $command */ $io->writeln($this->application()->name(), "white"); $io->writeln("Version: " . $this->application()->version(), "green"); $io->writeln(); $command = $this->application()->getCommand($command); $command->showHelp($io); } else { $this->application()->showHelp(); } }
public function execute(IOStream $io) { $cache = $this->application()->getCache(); $key = $this->input('key') || $this->input('option.file'); if ($key) { $response = $cache->delete($key); } else { $response = $cache->destroy(); } if ($response) { $io->writeln('Cache Successfully Cleared.', 'green'); } else { $io->showErr('Unable to clear cache'); } }
private function checkBower() { $this->io->writeln('Checking Node.js (npm) and Bower status:', 'green'); if (!$this->checkIsInstalled('npm')) { $this->io->showWarning('Node.js Package Manager (npm) is missing! Node.js Package Manager is needed to install/run bower, a powerful tool for front-end dependency management'); return false; } if (!$this->checkIsInstalled('bower')) { $this->io->showWarning('bower is missing! bower is a powerful tool for front-end dependency management'); return false; } system('bower list'); $this->io->writeln(); return true; }
private function changeFolderPermissions($folder, $mode) { if (!empty($errors = chmodDirFiles($folder, $mode))) { foreach ($errors as $error) { $this->io->writeln("Unable to change permissions for {$error}", 'red'); } } }
public function execute(IOStream $io) { if ($this->options('environment')) { $this->application()->setEnvironment($this->options('environment')); } $mapper = $this->application()->getMapper(); if ($mapper->hasTable('migration_log')) { $mapper->dropTable('migration_log'); } $table = new Table('migration_log', [], $mapper); $res = $table->addColumn('id', 'integer', ['null' => false, 'primaryKey' => true, 'autoIncrement' => true])->addColumn('migration', 'string')->addColumn('batch', 'integer')->addTimestamps()->create(); if ($res) { $io->writeln('Migration table setup successfully', 'green'); } else { $io->showErr('Unable to create migration table in database'); } }
public function execute(IOStream $io) { $docRoot = $this->application()->publicFolder(); $docRoot = $this->options('docroot', $docRoot); $router = $this->options('router', "{$docRoot}/index.php"); $host = $this->options('host', 'localhost'); $port = $this->options('port', '8000'); $binary = PHP_BINARY; $base = $this->application()->basePath(); chdir($docRoot); $io->writeln("Core Framework Development Server started at http://{$host}:{$port}/"); if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '3.8.0') >= 0) { passthru("{$binary} -m server -v Server.Type=proxygen -v Server.SourceRoot={$base}/ -v Server.IP={$host} -v Server.Port={$port} -v Server.DefaultDocument={$router} -v Server.ErrorDocument404={$router}"); } else { passthru("{$binary} -S {$host}:{$port} {$router}"); } }
private function showStatus() { /** @var Migration[] $all */ $all = Migration::find(); foreach ($all as $i => $model) { $all[$i] = $model->toArray(); } $headers = ['id', 'migration', 'batch', 'created_at', 'modified_at']; array_unshift($all, $headers); $this->io->showTable($all); }
public function execute(IOStream $io) { $io->writeln('Optimizing Core Framework...', 'green'); if ($this->getOptions('all') || $this->getOptions('a')) { putenv('COMPOSER_HOME=' . $this->application()->basePath() . '/vendor/bin/composer'); $input = new ArrayInput(['command' => 'clearcache']); $composer = new Application(); $composer->setAutoExit(false); $composer->run($input); $input = new ArrayInput(['command' => 'dumpautoload']); $composer = new Application(); $composer->setAutoExit(false); $composer->run($input); } $cache = $this->application()->getCache(); $config = $this->application()->getConfig(); $router = $this->application()->getRouter(); $cache->delete('framework.conf'); $cache->delete('routes'); $router->loadRoutes(); $router->cacheRoutes(); $cache->put('framework.conf', $config->all(), $config->get('app.ttl', 60)); $io->writeln('Core Framework Application Optimized successfully!', 'green'); }
/** * @inheritdoc */ public function showHelp(IOStream $io) { $io->writeln('Usage:', 'yellow'); // Generate syntax $io->write("{$this->name} ", 'green'); /** @var Argument $argument */ foreach ($this->arguments as $name => $argument) { if ($argument->isRequired()) { $io->write("{$name} "); } else { $io->write("[{$name}] ", 'yellow'); } } /** @var Option $option */ foreach ($this->options as $name => $option) { $color = ""; $value = ""; if (!$option->isRequired()) { $color = "yellow"; $io->write("[", $color); } else { $value = "=(value)"; } if ($option->hasShortName()) { $io->write("-{$option->getShortName()}{$value} | ", $color); } $io->write("--{$option->getName()}", $color); if (!$option->isRequired()) { $io->write("]", $color); } } $io->writeln(); $io->writeln(); $io->writeln("Description:", 'yellow'); $io->writeln("{$this->getDescription()}"); $io->writeln(); if (empty($this->arguments) && empty($this->options)) { $io->writeln("This command has no arguments or options!"); return; } // Argument(s) description if (!empty($this->arguments)) { $io->writeln("Arguments:", 'yellow'); foreach ($this->arguments as $i => $argument) { $optionalTxt = ""; if (!$argument->isRequired()) { $optionalTxt = "(optional)"; } //$io->writeln("{$argument->getName()} {$argument->getDescription()} {$optionalTxt}"); $io->write("{$argument->getName()} {$optionalTxt}", 'green', null, "%-40s "); $io->write($argument->getDescription(), 'white', null, "%s" . PHP_EOL); } $io->writeln(); foreach ($this->arguments as $i => $argument) { if ($argument->hasValidation()) { $io->writeln(); $io->writeln("Valid {$argument->getName()} Options:", 'yellow'); foreach ($argument->getValidations() as $index => $validator) { if ($validator instanceof OptionsValidator) { foreach ($validator->getOptions() as $value => $desc) { $io->write(" {$value}", 'green', null, "%-40s "); $io->write($desc, 'white', null, "%s" . PHP_EOL); } } } } } $io->writeln(); } // Option(s) description if (!empty($this->options)) { $io->writeln("Options:", 'yellow'); foreach ($this->options as $name => $option) { $requiredTxt = ""; if ($option->isRequired()) { $requiredTxt = "=(value)"; } //$io->writeln("{$option->getName()} {$option->getDescription()} {$optionalTxt}"); $io->write("--{$option->getName()}{$requiredTxt} | -{$option->getShortName()}{$requiredTxt} ", "green", null, "%-40s "); $io->write($option->getDescription(), "white", null, "%s" . PHP_EOL); } $io->writeln(); } }
public function clearcache(IOStream $io, $verbose = true) { $cache = $this->application()->getCache(); if ($cache->delete('routes') && $verbose) { $io->writeln('Cached routes cleared successfully!', 'green'); } else { $io->showErr('Unable to delete cached routes'); } }