This is my PrestaShop module file structure:
-mymodule/
--src/
--mymodule.php
---Presta/
---Webhooks.php
----Controller/
-----MyPrestaController.php
mymodule.php cannot find Webhooks.php class, I've tried use in mymodule.php, but still it provides errors:
ClassNotFoundException in mymodule.php line 55:
Attempted to load class "Webhooks" from namespace "src\Presta".
Did you forget a "use" statement for another namespace?
When I try to use autoload/include/require in mymodule.php it throws fatal errors, because autoload initialize stuff(from my module vendor) that shouldn't be initialized in mymodule.php. GuzzleClient gets crazy while browsing website:
Catchable Fatal Error: Argument 3 passed to
GuzzleHttp\Client::request() must be of the type array, string given,
called in /usr/local/ampps/www/presta/modules/mymodule/vendor/guzzlehttp/guzzle/src/Client.php on line 89 and defined
I don't want to put all hook logic in mymodule.php and I have other classes that I need to implement in webhook methods. Is there any way to use other classes in main module file(mymodule.php)? Am I missing something?
You need to call your class with full path or declare a
use
on top of your module file. I don't know exactly what namespaceWebhooks
is under but something like this:or