/** * Install the TwoStream package * * @return void */ public function install() { $disk = Storage::createLocalDriver(['driver' => 'local', 'root' => app_path()]); $this->info('Publishing required files', 1); $this->call('vendor:publish', ['--provider' => strtolower(TwoStream::PACKAGE), '--tag' => 'required'], 2); $this->info('Applying your app\'s namespace <comment>[' . $this->appNamespace . ']</comment>', 1); foreach (TwoStreamServiceProvider::pathsToPublish(strtolower(TwoStream::PACKAGE), 'required') as $required) { $required = str_replace(app_path(), '', $required); $originalFile = $disk->get($required); $file = str_replace('{{namespace}}', $this->appNamespace, $originalFile); if ($file != $originalFile) { $this->info('Setting namespace for <comment>[/app' . str_replace([app_path(), '.php', '.stub'], '', $required) . ']</comment>', 2); $disk->put($required, $file); if (!$disk->exists(str_replace('.stub', '.php', $required))) { $disk->move($required, str_replace('.stub', '.php', $required)); } } } $this->info('Cleaning up...', 1); $files = $disk->allFiles('Ws'); foreach ($files as $key => $file) { if (preg_match('/\\.stub$/', $file)) { $disk->delete($file); } } }
/** * Check if the TwoStream Package is installed * * @return bool */ protected function isInstalled() { $disk = Storage::createLocalDriver(['driver' => 'local', 'root' => app_path()]); foreach (TwoStreamServiceProvider::pathsToPublish(strtolower(TwoStream::PACKAGE), 'required') as $required) { if (!$disk->exists(str_replace('.stub', '.php', $required))) { return false; } } return true; }