I created a shopware plugin but when I tried to add an event subscriber, I got this error: " (2/2) ReflectionException The autoloader expected class „ConfigurationPlugin\Subscriber\Subscriber“ to be defined in file „/usr/www/users/ftp01000/_abodemo/custom/plugins/ConfigurationPlugin/src//Subscriber/Subscriber.php“. The file was found but the class was not in it, the class name or namespace probably has a typo."
In order to correct my class name, I renamed it from „ConfigSubscriber“ to just „Subscriber“. This lead to the server being crashed without prompting an error.
I changed the name of the class bach to „ConfigSubscriber“ and now I am getting this new error:
„Compile Error: Cannot declare class ConfigurationPlugin\Subscriber\ConfigSubscriber, because the name is already in use“.
Kindly help me out.
@hasan.h Could you post your subscriber here?
Also please make sure, that there is just one file in your Subscriber directory and it is named Subscriber.php.
and yes, there is only one file named Subscriber.php in my Subscriber directory.
@hasan.h Looks good on first glance. Have you tried to clear the cache?
I did. I typed bin/console cache:Clear in git bash but its still returning this error
Well, then maybe check the services.xml file. Perhaps it still contains ConfigSubscriber ? Or search for ‚ConfigSubscriber‘ in your whole project. It has to be somewhere…
and ConfigSubscriber is nowhere else in my project. As mentioned in the original post, this was giving some other error before I changed the name of class and changed it again.
Try to replace your current <service …> with this:
<service id="ConfigurationPlugin\Subscriber\Subscriber">
<argument type="service" id="Shopware\Core\System\SystemConfig\SystemConfigService"/>
<tag name="kernel.event_subscriber"/>
</service>
OK, now I see it. In your screenshot, the class in named ConfigSubscriber:
It should be named Subscriber. Then everything should click together.
Thankyou. bin/console isnt showing any error now but the website (client server) isnt letting me login. Any idea why is it showing me this error:
An error occurred while loading the web debug toolbar.