cron - Symfony ExcelBundle in Command -


i'll try like:

<?php namespace exportbundle\command;  use symfony\bundle\frameworkbundle\command\containerawarecommand; use symfony\component\console\command\command; use symfony\component\console\input\inputargument; use symfony\component\console\input\inputinterface; use symfony\component\console\input\inputoption; use symfony\component\console\output\outputinterface; use symfony\component\httpfoundation\responseheaderbag;  // extending containerawarecommand can have access $container // can see how it's used in method execute class hellocommand extends containerawarecommand {      // method used register command name, arguments requires (if needed)     protected function configure() {         // register optional argument here. more below:         $this->setname('hello:world')             ->addargument('name', inputargument::optional);     }      // method called once command being called fron console.     // $input - can access arguments passed terminal (if given/required)     // $output - use show response in terminal     protected function execute(inputinterface $input, outputinterface $output) {           // ask service excel object        $phpexcelobject = $this->get('phpexcel')->createphpexcelobject();         $phpexcelobject->getproperties()->setcreator("liuggio")            ->setlastmodifiedby("giulio de donato")            ->settitle("office 2005 xlsx test document")            ->setsubject("office 2005 xlsx test document")            ->setdescription("test document office 2005 xlsx, generated using php classes.")            ->setkeywords("office 2005 openxml php")            ->setcategory("test result file");        $phpexcelobject->setactivesheetindex(0)            ->setcellvalue('a1', 'hello')            ->setcellvalue('c1', 'hello')            ->setcellvalue('b2', 'world!');        $phpexcelobject->getactivesheet()->settitle('simple');        // set active sheet index first sheet, excel opens first sheet        $phpexcelobject->setactivesheetindex(0);          // create writer         $writer = $this->get('phpexcel')->createwriter($phpexcelobject, 'excel2007');         // save method documented in official phpexcel library         $writer->save('filename.xlsx');           // return symfony response (a view or or thrown error !!!)         return "a symfony response";             $greetline = $input->getargument('name')              ? sprintf('hey there %s', $input->getargument('name'))              : 'hello world called without arguments passed!'         ;          $output->writeln($greetline);     }  } 

but throw me error:

[symfony\component\debug\exception\undefinedmethodexception] attempted call undefined method named "get" of class "exportbundle\command\hellocommand". did mean call e.g. "getaliases", "getapplication", "getdefinition", "getdescription", "gethelp", "gethelper" , "gethelperset", "getname", "getnativedefinition", "getprocessedhelp", "getsynopsis" or "getusages"?

in line:

$phpexcelobject = $this->get('phpexcel')->createphpexcelobject(); 

work fine in controller in command not.

how can make work in command?


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -