Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function publish($filename, $destination, $merge = self::FOLLOW, $mode = FilesInterface::READONLY)
 {
     if (!$this->files->isFile($filename)) {
         throw new PublishException("Given '{$filename}' is not valid file.");
     }
     //wtf? always empty
     if (empty($relativeFilename)) {
         $relativeFilename = $this->files->normalizePath($this->files->relativePath($filename, $this->directories->directory('root')));
     }
     //wtf?
     if (empty($relativeDestination)) {
         $relativeDestination = $this->files->relativePath($destination, $this->directories->directory('root'));
     }
     if ($this->files->exists($destination)) {
         if ($this->files->md5($destination) == $this->files->md5($filename)) {
             $this->logger()->debug("File '{relativeFilename}' already published and latest version.", compact('relativeFilename', 'destination'));
             //Nothing to do
             return;
         }
         if ($merge == self::FOLLOW) {
             //We are not allowed to replace file
             $this->logger()->warning("File '{relativeFilename}' already published and can not be replaced.", compact('relativeFilename', 'destination'));
             return;
         }
     }
     $this->logger()->info("Publish file '{relativeFilename}' to '{relativeDestination}'.", compact('relativeFilename', 'relativeDestination'));
     $this->ensureDirectory(dirname($destination), $mode);
     $this->files->copy($filename, $destination);
     $this->files->setPermissions($destination, $mode);
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function publish(PublisherInterface $publisher, DirectoriesInterface $directories)
 {
     /**
      * Publishing all module visual resources. We are going to overwrite existed files.
      */
     $publisher->publishDirectory(__DIR__ . '/../resources', $directories->directory('public') . 'resources', PublisherInterface::OVERWRITE);
 }
Пример #3
0
 /**
  * @param DirectoriesInterface $directories
  * @param FilesInterface       $files
  * @param EncrypterConfig      $config
  */
 public function perform(DirectoriesInterface $directories, FilesInterface $files, EncrypterConfig $config)
 {
     $envFilename = $directories->directory('root') . '.env';
     if (!$files->exists($envFilename)) {
         $this->writeln("<fg=red>'env.' file does not exists, unable to sek encryption key.</fg=red>");
     }
     $files->write($envFilename, str_replace($config->getKey(), Strings::random(32), $files->read($envFilename)));
     $this->writeln("<info>Encryption key has been successfully updated.</info>");
 }
Пример #4
0
 /**
  * @param DirectoriesInterface $directories
  */
 public function perform(DirectoriesInterface $directories)
 {
     $host = $this->argument('host') . ':' . $this->option('port');
     $this->writeln("<info>Development server started at <comment>{$host}</comment></info>");
     $this->writeln("Press <comment>Ctrl-C</comment> to quit.");
     $process = new Process('"' . PHP_BINARY . "\" -S {$host} \"{$directories->directory('framework')}../server.php\"", $directories->directory('public'), null, null, $this->option('timeout'));
     $process->run(function ($type, $data) {
         if ($type != Process::ERR) {
             //First character contains request type, second is space
             if ($data[0] == 'S' || $this->isVerbosity()) {
                 $this->writeln(substr($data, 2));
             }
         }
     });
 }
Пример #5
0
 /**
  * @param FilesInterface       $files
  * @param DirectoriesInterface $directories
  */
 public function perform(FilesInterface $files, DirectoriesInterface $directories)
 {
     $cacheDirectory = $directories->directory('cache');
     if (!$files->exists($cacheDirectory)) {
         $this->writeln("Cache directory is missing, no cache to be cleaned.");
         return;
     }
     $this->isVerbosity() && $this->writeln("<info>Cleaning application runtime cache:</info>");
     foreach ($files->getFiles($cacheDirectory) as $filename) {
         $files->delete($filename);
         if ($this->isVerbosity()) {
             $this->writeln($files->relativePath($filename, $cacheDirectory));
         }
     }
     $this->writeln("<info>Runtime cache has been cleared.</info>");
 }
Пример #6
0
 /**
  * @param DirectoriesInterface $directories
  * @param FilesInterface       $files
  */
 protected function ensurePermissions(DirectoriesInterface $directories, FilesInterface $files)
 {
     $this->writeln("<info>Verifying runtime directory existence and file permissions...</info>");
     $runtime = $directories->directory('runtime');
     if (!$files->exists(directory('runtime'))) {
         $files->ensureDirectory(directory('runtime'));
         $this->writeln("Runtime data directory was created.");
         return;
     }
     foreach ($files->getFiles(directory('runtime')) as $filename) {
         //Both file and it's directory must be writable
         $files->setPermissions($filename, FilesInterface::RUNTIME);
         $files->setPermissions(dirname($filename), FilesInterface::RUNTIME);
     }
     $this->writeln("Runtime directory permissions were updated.");
 }
Пример #7
0
 /**
  * @param string $config
  * @return string
  * @throws RegistratorException
  */
 protected function configFilename($config)
 {
     $filename = $this->directories->directory('config') . $config . Configurator::EXTENSION;
     if (!$this->files->exists($filename)) {
         throw new RegistratorException("Unable to find filename for config '{$config}'.");
     }
     return $filename;
 }
Пример #8
0
 /**
  * Get unique file hash to improve resources caching.
  *
  * @todo add ability to disable this option
  * @param string $uri
  * @return string
  */
 protected function fileHash($uri)
 {
     return base_convert($this->files->time($this->directories->directory('public') . $uri), 10, 32);
 }
Пример #9
0
 /**
  * {@inheritdoc}
  */
 public function publish(PublisherInterface $publisher, DirectoriesInterface $directories)
 {
     $publisher->publishDirectory(__DIR__ . '/../resources', $directories->directory('public') . 'resources', PublisherInterface::OVERWRITE);
 }
Пример #10
0
 /**
  * {@inheritdoc}
  */
 public function publish(PublisherInterface $publisher, DirectoriesInterface $directories)
 {
     $publisher->publish(__DIR__ . '/config/security.php', $directories->directory('config') . 'modules/security.php', PublisherInterface::FOLLOW);
 }
Пример #11
0
 /**
  * @param PublisherInterface   $publisher
  * @param DirectoriesInterface $directories
  */
 public function publish(PublisherInterface $publisher, DirectoriesInterface $directories)
 {
     $publisher->publish(__DIR__ . '/config/vault.php', $directories->directory('config') . 'modules/vault.php', PublisherInterface::FOLLOW);
     $publisher->publishDirectory(__DIR__ . '/../resources', $directories->directory('public') . 'resources', PublisherInterface::OVERWRITE);
 }