wp-cli / wp-config-transformer

Programmatically edit a wp-config.php file
MIT License
81 stars 25 forks source link

Cannot declare class WPConfigTransformer, because the name is already in use #51

Closed 87jaydeepsingh closed 5 months ago

87jaydeepsingh commented 6 months ago

Hello Team,

I am using this with PHP everything works well on frontend but when I am running the wp plugin list command using wpcli it gives me an error

PHP Fatal error: Cannot declare class WPConfigTransformer, because the name is already in use in

I have noticed one thing there is no namespace used with the class so class names must be conflicting because wp-cli also used the same library.

So should I put the namespace and use it or you will fix this issue on your side and I will take the new source code?

Thanks,

danielbachhuber commented 5 months ago

Thanks for the question, @87jaydeepsingh

So should I put the namespace and use it or you will fix this issue on your side and I will take the new source code?

We won't add the namespace on our end. You're welcome to, or you could conditionally load the class on the frontend when the WP_CLI constant isn't defined:

if ( ! defined( 'WP_CLI' ) || ! WP_CLI ) {
    // load the class
}