protected function start() { $this->setFtp(); $this->setGit(); if ($commits = $this->getCommits()) { $this->error('ya esta iniciado el proyecto en el servidor'); } else { $this->success('iniciamos el proyecto en el servidor'); $base_path = $this->container->get('config')->get('paths.root'); $files = $this->rglob($base_path . '/*'); $files = $this->ignoreFiles($files); // create a zip $zip_path = __DIR__ . '/../../temp/deploy.zip'; $zip = Zip::create($zip_path); foreach ($files as $n => $file) { $rfile = str_replace($base_path . '/', '', $file); $zip->add($file, $rfile); } $zip->add($base_path . '/.htaccess', '.htaccess'); $zip->add($base_path . '/httpdocs/.htaccess', 'httpdocs/.htaccess'); $zip->add($base_path . '/httpdocs/.maintenance.php', 'httpdocs/.maintenance.php'); $zip->close(); $this->ftp->put('httpdocs/Zip.php', __DIR__ . '/../../vendor/buuum/zip/src/Zip/Zip.php'); $this->ftp->put('deploy.zip', $zip_path); unlink($zip_path); $temp_unzip_path = __DIR__ . '/_un'; file_put_contents($temp_unzip_path, $this->getPlantillaUnzip()); $this->ftp->put('httpdocs/unzip.php', $temp_unzip_path); unlink($temp_unzip_path); // initalize temp and log folder with 0777 $this->ftp->mkdir('temp'); $this->ftp->chmod(0777, 'temp'); $this->ftp->mkdir('log'); $this->ftp->chmod(0777, 'log'); // initialize commits/commits.json $temp_commits_path = __DIR__ . '/_c'; $this->createCommits($temp_commits_path); $this->ftp->put('commits/commits.json', $temp_commits_path); unlink($temp_commits_path); // descomprimimos el zip en servidor $host = 'http://' . $this->environment['host'] . '/unzip.php'; file_get_contents($host); sleep(2); // change config.php with environment required $temp_config_path = __DIR__ . '/_conf.php'; $config_path = $this->container->get('config')->get('paths.config'); $arr = (include $config_path); $arr['environment'] = $this->environment_name; file_put_contents($temp_config_path, "<?php return " . var_export($arr, true) . ";"); $this->ftp->put('app/config.php', $temp_config_path); unlink($temp_config_path); } }