Composer autoloader working in local but not in server

谁说胖子不能爱 提交于 2019-12-24 02:48:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!