Skip to content
Advertisement

Access Command OutputInterface within a Doctrine Fixtures Load

I’m generating a huge amount of data fixtures using the awesome Faker Library, also using lorempixel.com to have some random images in my Symfony2 project. This takes some time (currently ~ 10 Minutes), so I was wondering if it is possible to access the Command OutputInterface somehow through the container interface and print the progress this way instead of echo'ing everything..

Maybe also to have a nice output with ProgressBar

Advertisement

Answer

It looks like ConsoleOutput doesn’t need anything special and can be instantiated directly.

use SymfonyComponentConsoleOutputConsoleOutput;

// ...

public function load(ObjectManager $manager)
{
    $output = new ConsoleOutput();

    $output->writeln('<info>this works... </info>');
} 
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement