wp-media / wp-rocket-cli

WP CLI interface for the WP Rocket plugin
74 stars 37 forks source link

Initial version of subcommand bedrock init #58

Open s-allius opened 1 year ago

s-allius commented 1 year ago

This pull request deals with some problems that arise from the use of Bedrock Roots. There is a conflict around the definition of WP_CACHE. WP rocket normally sets and deletes this in the wp-config.php file. Under bedrock this definition is moved into the bedrock configuration (usually the .env file). In wp rocket there is a filter rocket_set_wp_cache_constant to switch off writing to wp-config.php. At the moment this filter is not respected by the wp-cli subcommands for wp rocket. The solution could be to use the new command wp rocket bedrock-init. The user can set the flag WP_CACHE in his bedrock config and call wp rocket bedrock-init during the deployment.This initialises the WP rocket plugin and activates or deactivates it depending on the value of WP_CACHE.

The pull request addresses another issue that occurs on shared web servers. There, the absolute paths from the point of view of the shared web server differ from the paths of the user application. Normally WP Rocket detects this during the installation by means of the web server configuration. When using wp-cli, wp rocket does not run in the context of a web server and the paths in advanced-cache.php are set incorrectly. With the parameter '--vhost-dir' an appropriate prefix can be specified and the file advanced-cache.php is created correctly for the target web server