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.
- At some point typo3/surf must create a temporary php file, which can be accessed
- later: after the switch was done and the new deployment is reachable via the frontend.
How can I configure typo3/surf to access the previously generated OPcache clearing script via the frontend on a BasicAuth protected environment?
Configuring typo3/surf to reset the PHP OPcache1
Four steps are basically necessary to configure the OPcache clearing/reset script:
\TYPO3\Surf\Task\Php\WebOpcacheResetCreateScriptTask
\TYPO3\Surf\Task\Php\WebOpcacheResetCreateScriptTask
the an early stage (e.g.package
but definitely beforetransfer
)\TYPO3\Surf\Task\Php\WebOpcacheResetExecuteTask
\TYPO3\Surf\Task\Php\WebOpcacheResetExecuteTask
after stageswitch
Here are the necessary snippets for your onInitialize function2 within your deployment configuration script:
Set task options for the "Create Script Task":
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:Set task options for the "Execute Task":
Activate both Tasks:
This answer shows only the necessary parts for the OPcache reset process!
Please check also the TYPO3 CMS deployment configuration example in the official documentation.
Footnotes
1 This answer is based on typo3/surf GIT branch dev-master, version 2.x
2 Example where to place the mentioned snippets: