php MongoDB\Driver\Manager not found when executing Symfony command -
ok, have project mongo connection works fine when viewing pages etc. when try load manage class in command (containerawarecommand) class not found exception:
[symfony\component\debug\exception\classnotfoundexception]
attempted load class "manager" namespace "mongodb\driver".
did forget "use" statement namespace?
i'm using symfony 3.2
here's do:
class testcommand extends containerawarecommand { protected function configure() { $this->setname('testcommand:test') ->setdescription('test...') ->sethelp('test...'); } protected function execute(inputinterface $input, outputinterface $output) { $db = new manager("mongodb://localhost:27017"); $output->writeln([ 'test', '========================', '', ]); } }
i import driver with:
use mongodb\driver\manager;
phpstorm recognizes import.
any ideas stops class loading? once again, loads when navigate pages etc.
thanks!
update (as requested) !
registered service:
services: test.service: class: appbundle\test\testservice public: true
the service:
namespace appbundle\test; use mongodb\driver\manager; class testservice { public function foo() { $manager = new manager("mongodb://localhost:27017"); } }
added execute method:
$ts = $this->getcontainer()->get("test.service"); $ts->foo();
result:
[symfony\component\debug\exception\classnotfoundexception]
attempted load class "manager" namespace "mongodb\driver".
did forget "use" statement namespace?
what missing?
another update
i noticed couldn't switch production because of same, more general, error.
turns out can't use namespaces can class (manager) via qualified name @ run time only!!!
Comments
Post a Comment