Reputation: 565
On a TYPO3 project I'm working the Production/Staging (or Production/Dev, or any other) environment is protected by HTTP BasicAuth (basic access authentication).
The instance get's deployed via typo3/surf.
How can I configure typo3/surf to access the previously generated OPcache clearing script via the frontend on a BasicAuth protected environment?
Upvotes: 1
Views: 257
Reputation: 565
\TYPO3\Surf\Task\Php\WebOpcacheResetCreateScriptTask
\TYPO3\Surf\Task\Php\WebOpcacheResetCreateScriptTask
the an early stage (e.g. package
but definitely before transfer
)\TYPO3\Surf\Task\Php\WebOpcacheResetExecuteTask
\TYPO3\Surf\Task\Php\WebOpcacheResetExecuteTask
after stage switch
Since the "Respect WebDirectory" patch, the path to the script must not to be configured manually as it automatically uses the right WebDirectory path (which is set via options beforhand).
If you are using an older typo3/surf version or you have any special requirement you can set option scriptBasePath
to set the absolute path to the resulting file:
# In this example, I have to set the absolute path for the resulting php file.
# Since the deployment run in GitLab CI I get the path to the root of the project's GIT
# repository via the environment variable `CI_PROJECT_DIR`. Since the path to the webDirectory
# inside the GIT repository is `<GitRepoRootFOlder>/app/web` I add it manually and concatenate
# it as final string for the option `scriptBasePath`:
$workflow->setTaskOptions(\TYPO3\Surf\Task\Php\WebOpcacheResetCreateScriptTask::class, [
'scriptBasePath' => \TYPO3\Flow\Utility\Files::concatenatePaths([getenv('CI_PROJECT_DIR'), '/app/web']),
]);
At this point, we provide username and password
$workflow->setTaskOptions('TYPO3\\Surf\\Task\\Php\\WebOpcacheResetExecuteTask', [
'baseUrl' => $application->getOption('baseUrl'),
'stream_context' => [
'http' => [
'header' => 'Authorization: Basic '.base64_encode("username:password"),
],
],
]);
$workflow->beforeStage('transfer', \TYPO3\Surf\Task\Php\WebOpcacheResetCreateScriptTask::class, $application)
->afterStage('switch', \TYPO3\Surf\Task\Php\WebOpcacheResetExecuteTask::class, $application);
Please check also the TYPO3 CMS deployment configuration example in the official documentation.
1 This answer is based on typo3/surf GIT branch dev-master, version 2.x
2 Example where to place the mentioned snippets:
$deployment->onInitialize(function () use ($deployment, $application) {
/** @var SimpleWorkflow $workflow */
$workflow = $deployment->getWorkflow();
# the mentioned snippets have to be placed next to your existing configuration
});
Upvotes: 2