/** * Install a bundle from by downloading a Zip. * * @param string $url * @param array $bundle * @param string $path * @return void */ protected function zipball($url, $bundle, $path) { $work = path('storage') . 'work/'; // When installing a bundle from a Zip archive, we'll first clone // down the bundle zip into the bundles "working" directory so // we have a spot to do all of our bundle extration work. $target = $work . 'laravel-bundle.zip'; File::put($target, $this->download($url)); $zip = new \ZipArchive(); $zip->open($target); // Once we have the Zip archive, we can open it and extract it // into the working directory. By convention, we expect the // archive to contain one root directory with the bundle. mkdir($work . 'zip'); $zip->extractTo($work . 'zip'); $latest = File::latest($work . 'zip')->getRealPath(); @chmod($latest, 0777); // Once we have the latest modified directory, we should be // able to move its contents over into the bundles folder // so the bundle will be usable by the develoepr. File::mvdir($latest, $path); File::rmdir($work . 'zip'); $zip->close(); @unlink($target); }
/** * Upgrade the given bundles for the application. * * @param array $bundles * @return void */ public function upgrade($bundles) { if (count($bundles) == 0) { $bundles = Bundle::names(); } foreach ($bundles as $name) { if (!Bundle::exists($name)) { echo "Bundle [{$name}] is not installed!"; continue; } // First we want to retrieve the information for the bundle, such as // where it is currently installed. This will allow us to upgrade // the bundle into it's current installation path. $location = Bundle::path($name); // If the bundle exists, we will grab the data about the bundle from // the API so we can make the right bundle provider for the bundle, // since we don't know the provider used to install. $response = $this->retrieve($name); if ($response['status'] == 'not-found') { continue; } // Once we have the bundle information from the API, we'll simply // recursively delete the bundle and then re-download it using // the correct provider assigned to the bundle. File::rmdir($location); $this->download($response['bundle'], $location); echo "Bundle [{$name}] has been upgraded!" . PHP_EOL; } }
/** * Delete a bundle's assets from the public directory * * @param string $bundle * @return void */ public function unpublish($bundle) { if (!Bundle::exists($bundle)) { echo "Bundle [{$bundle}] is not registered."; return; } File::rmdir(path('public') . 'bundles' . DS . $bundle); echo "Assets deleted for bundle [{$bundle}]." . PHP_EOL; }
public static function remove($module_slug) { if (isset($module_slug) and !empty($module_slug)) { // Remove bundle files if (\File::rmdir(path('bundle') . $module_slug) === null) { static::$errors->add('installer', 'Module [' . $module_slug . '] was successfully removed.'); // // Remove published assets // if (File::rmdir(path('public') . 'bundles' . DS . $module_slug) === null) { static::$errors->add('installer', 'Module assets for module [' . $module_slug . '] were successfully removed.'); return true; } else { static::$errors->add('installer', 'Failed to remove assets for module [' . $module_slug . '].'); return false; } } else { static::$errors->add('installer', 'Failed to remove module [' . $module_slug . '].'); return false; } } else { static::$errors->add('installer', 'Failed to remove module, invalid module slug'); return false; } }