Skip to content

Conversation

@MarcoRemy
Copy link
Contributor

@MarcoRemy MarcoRemy commented Sep 25, 2025

  • New feature
  • Docs added // TODO

Hello there,

This PR is a proposal. It addresses the PHP OPcache reset after a new release is published.

The idea was inspired by the TYPO3/Surf deployment project. It features two tasks which create and execute a simple PHP script to reset the OPcache. As the OPcache memory space of the web server differs from that of the CLI interpreter, the script must be executed by the web server. To achieve this, the PHP script is placed in the document root of the release and fetched from the web server after the release is published.

// TYPO3/Surf workflow
->beforeStage('transfer', \TYPO3\Surf\Task\Php\WebOpcacheResetCreateScriptTask::class, $application)
->afterStage('switch', \TYPO3\Surf\Task\Php\WebOpcacheResetExecuteTask::class, $application);

For Deployer, the mechanics were adapted into an recipe which consists of two grouped task

desc('Reset PHP OPcache');
task('deploy:reset_opcache', [
    'deploy:reset_opcache:prepare',
    'deploy:reset_opcache:execute',
]);

These tasks have not yet been included in any deployment recipe because they are still in the experimental stage.

There are several considerations to take into account:

  • The script must be placed in the public document root directory. This may not be the same as the release directory. Application recipes need to set reset_opcache_document_root to their specific path.
  • The document root should be writable for www user
  • In order to request the script from the web server, the URL must be set by reset_opcache_app_url. This configuration option likely needs improvement.
  • The fetch() function does not offer any options for handling untrusted HTTPS connections in development environments. Direct use of Httpie would be an alternative approach to solve this issue.
  • It works with Apache HTTP Server + PHP-FPM. However, I don't know how it applies to other web server software, e.g. nginx.

Please let me know what you think.

@Schrank
Copy link
Contributor

Schrank commented Sep 25, 2025 via email

@MarcoRemy
Copy link
Contributor Author

Thank you for your feedback. I was unaware of the cachetool recipe. As it already handles the opcache, I am going to close the PR.

@MarcoRemy MarcoRemy closed this Sep 26, 2025
@Schrank
Copy link
Contributor

Schrank commented Sep 26, 2025

Sorry for the time invested, although I'm happy that it solves your problem! <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants