Exemple #1
0
 private function bowerInstall()
 {
     if (!$this->checkIsInstalled('npm')) {
         if ($this->checkIsInstalled('brew')) {
             $this->io->writeln('Installing Node and npm:', 'green');
             system('brew install node');
         } else {
             $this->io->showErr('Node/npm not installed please install Node/npm, and then install bower (OR re-run this command)');
         }
         return;
     }
     if (!$this->checkIsInstalled('bower')) {
         $this->io->writeln('Installing bower:', 'green');
         system('npm install -g bower');
     }
     if (file_exists($this->application()->basePath() . '/bower.json')) {
         $this->io->writeln('Running bower:', 'green');
         system('bower install');
     } else {
         $value = $this->io->ask('Would you like to initialize bower?', 'yes', ['yes', 'no']);
         if ($value === 'yes') {
             system('bower init');
         }
     }
 }
 public function execute(IOStream $io)
 {
     $fileType = $this->input('fileType');
     $name = $this->input('name');
     if (!$fileType || !$name) {
         $io->showErr("Please specify the 'fileType' and 'name' for the given file. See below help for details");
         $this->showHelp($io);
         return;
     }
     $fileSystem = $this->application()->getFileSystem();
     $real = $this->getRealFolder($this->application()->appPath(), $fileType, $io);
     $appFolder = $real['folder'];
     $namespace = $real['namespace'];
     $name = $this->formatName($name, $fileType);
     $replace = ['{{$namespace}}' => $namespace, '{{$fileName}}' => $name, '{{$className}}' => $name];
     $stub = $fileSystem->getContents(__DIR__ . "/../Stubs/{$fileType}.stub");
     $content = str_replace(array_keys($replace), array_values($replace), $stub);
     $filePath = rtrim($appFolder, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name . '.php';
     if ($fileType === 'migration') {
         $migration = new Migration(['migration' => $name, 'batch' => 0]);
         $migration->save();
     }
     if ($fileSystem->write($filePath, $content)) {
         $io->writeln($name . ' file created successfully', 'green');
     } else {
         throw new \RuntimeException('Unable to create file ' . $filePath);
     }
 }
 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}.");
     }
 }
 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');
     }
 }
 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 runClass($class)
 {
     if (!strContains('\\', $class)) {
         $namespacedClass = $this->namespace . '\\' . $class;
     } else {
         $namespacedClass = $class;
         $parts = explode('\\', $class);
         $class = $parts[sizeof($parts) - 1];
     }
     if ($this->migrateRun($namespacedClass, $class)) {
         $this->io->writeln("Migration {$this->direction} in class {$namespacedClass} ran successfully!", 'green');
     } else {
         $this->io->showErr("Migration {$this->direction} in class {$namespacedClass} failed!");
     }
     if ($this->options('verbose')) {
         $this->io->writeln("Status:", 'green');
         $this->showStatus();
     }
 }
 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');
     }
 }