问题
I'm having trouble finding the reason why composer autoloader is not woking in our server. Made sure composer is installed in the server.
I am using it in a plugin in Wordpress. I'm trying to activate the plugin but it's returning an error. In my local the composer autoloader is working fine. All classes are being found.
Here's the error I'm getting in the server:
Plugin could not be activated because it triggered a fatal error.
Fatal error: Class 'App\Settings\Menu' not found in /home/myusername/mydomain.com/wp-content/plugins/myplugin/myplugin.php on line 17
Here's the composer setup:
{
"autoload": {
"psr-4": {
"App\\": "app"
}
},
"require": {
"infusionsoft/php-sdk": "1.3.*",
"activecampaign/api-php": "1.0.0",
"preluigi/ontraport": "dev-master"
}
}
Here's how I call the classes in the plugin file:
define( 'CFD__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
require_once(CFD__PLUGIN_DIR . 'vendor/autoload.php');
new App\Settings\Menu;
new App\Settings\Settings;
new App\Points\Points;
new App\Badge\Badge;
new App\Leaderboard\Leaderboard;
If you could advise me what else to check to find the problem, i would really appreciate it. Thank you!!!
来源:https://stackoverflow.com/questions/46021003/composer-autoloader-working-in-local-but-not-in-server