M
M
Maxim Lagoysky2019-03-07 12:56:28
symfony
Maxim Lagoysky, 2019-03-07 12:56:28

How to overcome error with namespace in symfony 4?

Good afternoon, I installed the longman/telegram-bot library, it works with basic commands, but when I create my own folder with my commands in the docks, it says that my commands should have a namespace

namespace Longman\TelegramBot\Commands\UserCommands;

but when i write this namespace i get an error
Expected to find class "App\Social\TelegramCommands\TestCommand" in file "/var/www/test.com/src/Social/TelegramCommands/TestCommand.php" while importing services from resource "../src/*", but it wasn't found! Check the namespace prefix used with the resource in /var/www/test.com/config/services.yaml (which is loaded in resource "/var/www/test.com/config/services.yaml").

how to overcome it? I think I need to do something in service.yaml, if I haven’t touched it yet and I had it like that during installation and remained.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BoShurik, 2019-03-07
@lagoy

Put these commands in a separate folder (not src) and write the composer.jsonappropriate namespace for them in the autoload. But in fact, in the end, you will not be able to integrate this library with symfony (more precisely, it will work, but these will be crutches), because it is not possible to pass your dependencies to the constructor

"autoload": {
    "psr-4": { "Longman\\TelegramBot\\Commands\\": "commands/" }
},

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question