3

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!!!

Code Diary
  • 417
  • 2
  • 7
  • 17
  • 1
    Make sure you have run Composer in the plugin directory on the live server to install composer dependency packages... – Muhammad Asadullah Sep 03 '17 at 07:37
  • Hi @Mohsin, yes I checked the files in the vendor folder and the dependencies have been successfully downloaded. Hmm is there anything else I should do? – Code Diary Sep 03 '17 at 07:49
  • Not sure really... You might log into php error log and see if something else is triggering error, you said it is working on localhost, you might see in PHP Version change local vs live server and see if you can match live server to have Local php version etc... – Muhammad Asadullah Sep 03 '17 at 10:15
  • By any chance, is one of the differences between local environment and server to which is deployed to that the local environment has a case-insensitive filesystem, whereas the server environment has a case-sensitive filesystem? – localheinz Sep 03 '17 at 13:57

0 Answers0