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, and all of the // bundle contents should be stored in that directory. $zip->extractTo(path('storage').'work'); $latest = File::latest(dirname($target)); // 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. $path = $this->path($bundle); File::cpdir($latest->getRealPath(), path('bundle').$path); } /** * Create the path to the bundle's dirname. * * @param array $bundle * @return void */ protected function directory($bundle) { // If the installation target directory doesn't exist, we will create // it recursively so that we can properly install the bundle to the // correct path in the application. $target = dirname(path('bundle').$this->path($bundle)); if ( ! is_dir($target)) { mkdir($target, 0777, true); } } /** * Return the path for a given bundle. * * @param array $bundle * @return string */ protected function path($bundle) { return array_get($bundle, 'path', $bundle['name']); } }