Class cannot be found, but it’s available in the file, I get: Fatal Error: Uncaught Error: Class ‘BlocksBaseActivation’ not found

Question

Class cannot be found, but the declaration is correct. Here is my code:

Info-Wheel.php

if ( file_exists( dirname( __FILE__ ) . "/vendor/autoload.php" ) ) {
  require_once dirname( __FILE__ ) . "/vendor/autoload.php";
}


use BlocksBaseActivation;
use BlocksBaseDeactivation;
/**
 * The code that runs during plugin activation
 */
function iw_activate_plugin() {
>>  Activation::activate();
}
/**
 * The code that runs during plugin deactivation
 */
function iw_deactivate_plugin() {
  Deactivation::deactivate();
}
/**
 * Register Hooks for deactivation and activation
 */
register_activation_hook( __FILE__, "iw_activate_plugin" );
register_deactivation_hook( __FILE__, "iw_deactivate_plugin" );
/**
 * If class exists run it
 */
if ( class_exists( "IncInit" ) ) {
  BlocksInit::register_services();
}
Activation.php

 /**
  * Remove rewrite rules and then recreate rewrite rules.
  */
 class Activation {
  public static function activate() {
    flush_rewrite_rules(  );
   }
 }

I use composer, so I can use namespaces. Here is an image of my folder structure:
Folder Structure

In my opinion, the class Activation should be found and executed, but somehow WordPress can’t find it?
I have checked the names and copy-pasted them, just to be sure they’re the same. I marked line 56 with a double arrow.

Here is the full error message:


Fatal error: Uncaught Error: Class 'BlocksBaseActivation' not found in D:ProgrammeMAMPhtdocswordpresswp-contentpluginsInfo-WheelInfo-Wheel.php:56
Stack trace:
#0 D:ProgrammeMAMPhtdocswordpresswp-includesclass-wp-hook.php(287): iw_activate_plugin('')
#1 D:ProgrammeMAMPhtdocswordpresswp-includesclass-wp-hook.php(311): WP_Hook->apply_filters('', Array)
#2 D:ProgrammeMAMPhtdocswordpresswp-includesplugin.php(478): WP_Hook->do_action(Array)
#3 D:ProgrammeMAMPhtdocswordpresswp-adminplugins.php(193): do_action('activate_Info-W...')
#4 {main} thrown in D:ProgrammeMAMPhtdocswordpresswp-contentpluginsInfo-WheelInfo-Wheel.php on line 56

Edit: Here is a line from the autoloader:

"autoload": {
      "psr-4": {"Blocks": "./Blocks"}
  }
0
Mahnenwolf 2 months 0 Answers 9 views 0

Leave an answer