M
M
Maks Burkov2018-04-07 02:15:53
symfony
Maks Burkov, 2018-04-07 02:15:53

How to properly use the symphony/console component?

Error: Who can explain the error to me? I use only this component without the whole symphony.


There are no commands defined in the "/:" namespace.


class ConnectionCommand extends Command
{

    public function configure()
    {

        $this->setName('db-connect');
        $this->setDescription('command for connecting to database');
        $this->setHelp('db-connect command allow you to connect to existing database');

        $this->addArgument('usr',InputArgument::REQUIRED,'Database Username ..');
        $this->addArgument('password',InputArgument::REQUIRED,'Database Password ..');
        $this->addArgument('dsn',InputArgument::REQUIRED,'Database DSN ..');

    }

    public function execute(InputInterface $input, OutputInterface $output)
    {

       $output->writeln('Welcome To Data Generator!');
       $output->writeln('Before using the application, please fill in data for existing MySql connection to database!');
       $output->writeln(['1.Username, 2.Password, 3.Dsn']);

                $instance = new ConnectionInstance(

                    $input->getArgument('usr'),
                    $input->getArgument('password'),
                    $input->getArgument('dsn')
                );

                $connection = null;

                $log = new Logger('Connection');
                $log->pushHandler(new StreamHandler(__DIR__.'/connection.log'));
                $log->info('Connecting to database');

                try{
                    $connection = Connect::getInstance()->getConnection($instance);
                }catch (PDOException $e){
                    $log->info('Connection error message ..'.$e->getMessage());
                    $log->info('Connection error trace ..'.$e->getTraceAsString());
                }

                Container::getContainer()->mapTo($connection,$input->getArgument('usr'));
        }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question