0

I want to run the command : "composer install --prefer-dist" in a wordpress plugin in the hook register_activation_hook to install the require vendors. But when I trying to activating the plugin the error below is generate. Do you have a way to install the required composers when activate the plugin?

Fatal error: Uncaught Error: Class 'App\XXXXX' not found in /../wordpress/wp-content/plugins/my-plugin/my-plugin.php:54 Stack trace: #0 /../wordpress/wp-admin/includes/plugin.php(2300): include() #1 /../wordpress/wp-admin/plugins.php(191): plugin_sandbox_scrape('my-plugin/my-...') #2 {main} thrown in /../wordpress/wp-content/plugins/my-plugin/my-plugin.php on line 54

1

This is not how this should work. You should not be stunning shell commands from a plugin. The proper way to do this is to install dependencies before bundling for distribution.

3
  • I try to do this, but the dependencies I used have a huge size. I didn't want have a huge zip file like plugin. – CMH Apr 30 at 23:57
  • Well you have to. You can’t run composer from the plugin itself. – Jacob Peattie May 1 at 0:52
  • I found a WP Plugin allow me to upload huge and install huge plugin. It's: Upload Larger Plugins (fr.wordpress.org/plugins/upload-larger-plugins). – CMH Jun 3 at 21:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.