As you do automated deployments, you should check if the website is up and running
before switching it to the live site. This is called a Smoke Test. We will give
an example for using the built-in HTTP smoke test.

First, you need to create a virtual host with document root in “<deploymentDirectory>/releases/next/Web”.
While a deployment is running, the new website will be available under this URL and can
be used for testing.

In the test stage, the caches of the application is not flushed in order not to affect the live page.
A possible solution is to disable caches when running smoke tests in the test stage on “next” release.

If you are not able to set environment variables via .htaccess, you can use composer autoloading and a PHP file.
Thanks to the team of jweiland.net for this solution.

Root composer.json:

{"autoload":{"files":["scripts/typo3context.php"]}}

typo3context.php:

<?php// Set the application context in this file because it is not possible to set environment variables// via .htaccess e.g. on domainFACTORY/jweiland.net servers$context='Production';// detect application context by domainif(array_key_exists('HTTP_HOST',$_SERVER)){if(0===strpos($_SERVER['HTTP_HOST'],'next.')){$context='Testing';}}putenv('TYPO3_CONTEXT='.$context);