/** * @Route /genbundle/export */ public function exportAction() { $options = $this->app->getConfigurationLoader()->getBundlesLocation(); if (isset($options[$this->app->request()->get('name')])) { $location = \Raptor\Core\Location::get(\Raptor\Core\Location::CACHE); if ($location . "/Installer") { @mkdir($location . "/Installer/created", 0777, true); } $file = rand(10, 100000); $zip = new \Raptor\Util\Zip($location . "/Installer/created/" . $file . ".zip"); $zip->create($options[$this->app->request()->get('name')]); $this->app->response()->headers()->set('Content-Description', 'File Transfer'); $this->app->response()->headers()->set('Content-Disposition', 'attachment; filename="' . $this->app->request()->get('name') . '.zip"'); $this->app->contentType(\Raptor\Raptor::ZIP); $this->app->response()->headers()->set('Content-Transfer-Encoding', 'binary'); $content = file_get_contents($location . "/Installer/created/" . $file . ".zip"); @unlink($location . "/Installer/created/" . $file . ".zip"); return $content; } }
/** * Creating and Exporting a Zip * @Route /new/example/exportzip * */ public function exportZipAction() { $zip = new \Raptor\Util\Zip(); /** * Give the directory or a file to compress * in this case will be the Controller directory * of this bundle */ $zip->create(__DIR__); $this->app->contentType(\Raptor\Raptor::ZIP); $this->app->response()->headers()->set('Content-Disposition', 'attachment; filename="testing.zip"'); return $zip->output(); }