protected function setupDist()

in pgo/cases/symfony_demo_pdo_mysql/TrainingCaseHandler.php [48:81]


	protected function setupDist() : void
	{
		$case_dir = $this->conf->getCasesTplDir($this->getName());

		if (!is_dir($this->conf->getCaseWorkDir($this->getName()))) {
			echo "Setting up in '{$this->base}'\n";

			$ver = $this->conf->getSectionItem($this->getName(), "symfony_demo_version");
			$php = new PHP\CLI($this->conf);
			$php->exec($this->getToolFn() . " create-project symfony/symfony-demo " . $this->base . " " . $ver);

			copy("$case_dir/env.tpl", "{$this->base}/.env");
			copy("$case_dir/doctrine.yaml", "{$this->base}/config/packages/doctrine.yaml");
			unset($php);
		}

		$this->maria->up();

		$this->maria->query("DROP DATABASE IF EXISTS " . $this->getName());
		$this->maria->query("CREATE DATABASE " . $this->getName());

		$this->maria->import("$case_dir/blog.mysql", $this->getName());

		$this->maria->down(true);

		$port = $this->getHttpPort();
		$host = $this->getHttpHost();

		$vars = array(
			$this->conf->buildTplVarName($this->getName(), "docroot") => str_replace("\\", "/", $this->base . DIRECTORY_SEPARATOR . "public"),
		);
		$tpl_fn = $this->conf->getCasesTplDir($this->getName()) . DIRECTORY_SEPARATOR . "nginx.partial.conf";
		$this->nginx->addServer($tpl_fn, $vars);
	}