Error when activating a custom plugin on production server

I'm currently developing a custom plugin. All works well on my local dev environment (Local by Flywheel), but, on production environment, I'm unable to activate the plugin. I get this error message:

Fatal error: Class 'Activate' not found in /datas/vol3/w4a156338/var/www/my-website/htdocs/wp-content/plugins/ads-toolbox/ads-toolbox.php on line 54

The 'ads-toolbox.php' file it the plugin main php file and it contains the following:

function activate_adstoolbox_plugin() {
    Inc\Base\Activate::activate();
}
register_activation_hook( __FILE__, 'activate_adstoolbox_plugin' );

Line 54 is: Inc\Base\Activate::activate();

The class 'Activate' is inside the 'Activate.php' file located in 'inc/Base/' subdirectory and contains:

namespace Inc\Base;

class Activate
{
    public static function activate()
    {
        //Some code
    }

}

I do not understand why it works locally but not on my hosted site!?

Any idea ?

Topic oop plugin-development Wordpress

Category Web


Thanks to @the_hobbes and @Charles, I realized that the file Activate.php was not incorporated. By adding require_once plugin_dir_path( __FILE__ ) . 'inc/Base/Activate.php'; to my code as shown below, it works correctly:

function activate_adstoolbox_plugin() {
    require_once plugin_dir_path( __FILE__ ) . 'inc/Base/Activate.php';
    Inc\Base\Activate::activate();
}
register_activation_hook( __FILE__, 'activate_adstoolbox_plugin' );

Oops! Newbie's error ...

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.