From 79f67daa772268aa52ae3805016b84891f8dfed3 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Wed, 28 Aug 2024 19:17:59 +0200 Subject: [PATCH] Fix, update and re-activate symfony_demo PGO training case This test case had been deactivated a couple of years ago[1], because it was broken[2]. We fix it by switching to the composer installation of the Symfony demo application, update to version 2.4.0 (which is the last version supporting PHP 8.1, but apparently also runs fine with PHP 8.4), and re-activate it. [1] [2] --- pgo/cases/symfony_demo/TrainingCaseHandler.php | 9 ++++----- pgo/cases/symfony_demo/inactive | 0 pgo/cases/symfony_demo/nginx.partial.conf | 4 ++-- pgo/cases/symfony_demo/phpsdk_pgo.json | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) delete mode 100644 pgo/cases/symfony_demo/inactive diff --git a/pgo/cases/symfony_demo/TrainingCaseHandler.php b/pgo/cases/symfony_demo/TrainingCaseHandler.php index 9259378..d15fb9d 100644 --- a/pgo/cases/symfony_demo/TrainingCaseHandler.php +++ b/pgo/cases/symfony_demo/TrainingCaseHandler.php @@ -47,22 +47,23 @@ public function getJobFilename() : string protected function getToolFn() : string { - return $this->conf->getToolsDir() . DIRECTORY_SEPARATOR . "symfony.phar"; + return $this->conf->getToolsDir() . DIRECTORY_SEPARATOR . "composer.phar"; } protected function setupDist() : void { 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() . " demo " . $this->base); + $php->exec($this->getToolFn() . " create-project symfony/symfony-demo " . $this->base . " " . $ver); } $port = $this->getHttpPort(); $host = $this->getHttpHost(); $vars = array( - $this->conf->buildTplVarName($this->getName(), "docroot") => str_replace("\\", "/", $this->base . DIRECTORY_SEPARATOR . "web"), + $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); @@ -105,8 +106,6 @@ public function setupUrls() public function prepareInit(Tool\PackageWorkman $pw, bool $force = false) : void { - $url = $this->conf->getSectionItem($this->getName(), "symfony_phar_url"); - $pw->fetch($url, $this->getToolFn(), $force); } public function init() : void diff --git a/pgo/cases/symfony_demo/inactive b/pgo/cases/symfony_demo/inactive deleted file mode 100644 index e69de29..0000000 diff --git a/pgo/cases/symfony_demo/nginx.partial.conf b/pgo/cases/symfony_demo/nginx.partial.conf index b5498ce..5a6fd33 100644 --- a/pgo/cases/symfony_demo/nginx.partial.conf +++ b/pgo/cases/symfony_demo/nginx.partial.conf @@ -7,10 +7,10 @@ # symfony location / { - try_files $uri /app.php$is_args$args; + try_files $uri /index.php$is_args$args; } - location ~ ^/app\.php(/|$) { + location ~ ^/index\.php(/|$) { fastcgi_pass PHP_SDK_PGO_PHP_FCGI_HOST:PHP_SDK_PGO_PHP_FCGI_PORT; fastcgi_split_path_info ^(.+\.php)(/.*)$; include fastcgi_params; diff --git a/pgo/cases/symfony_demo/phpsdk_pgo.json b/pgo/cases/symfony_demo/phpsdk_pgo.json index 7048613..048ebf3 100644 --- a/pgo/cases/symfony_demo/phpsdk_pgo.json +++ b/pgo/cases/symfony_demo/phpsdk_pgo.json @@ -1,5 +1,5 @@ { - "symfony_phar_url": "https://get.symfony.com/symfony.phar", + "symfony_demo_version": "v2.4.0", "type": "web", "srv_http": "nginx", "srv_db": null