Cache rebuild
As usual with Drupal, first thing to try is always cache rebuild:
drupal cache-rebuild
If it didn't help, try once again. Just in case. You know, it's Drupal after all.
Restart the web server
In addition to the usual cache rebuild, the additional need to restart the web server is due to a decision in Drupal 8 to be "fast by default" and use the APC Classloader if it is available. It is faster, but it doesn't necessarily catch changes as you make them.
Disable APC Classloader for local install
To not have to restart your web server during development, you can set your local environment to not try to use a better-for-production class loader.
For instance, in your local.settings.php
add:
$settings['class_loader_auto_detect'] = FALSE;
Composer Merge Plugin
Try using the Composer Merge Plugin:
composer require wikimedia/composer-merge-plugin
and then in your root composer.json
:
{
"extra": {
"merge-plugin": {
"include": [
"core/composer.json",
"modules/mymodule/composer.json"
],
"recurse": true,
"replace": false,
"merge-extra": false
},
},
}
Sources: