سؤال

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

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى wordpress.stackexchange
scroll top