0

Currently I try to use this PHP Spreadsheet Bundle for Symfony 4: https://github.com/roromix/SpreadsheetBundle

But my attempts to use this bundle are not successful. Can't find it as a service (php bin/console debug:autowiring) and the way below is also wrong.

<?php
namespace App\Controller;

use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Roromix\Bundle\SpreadsheetBundle\RoromixSpreadsheetBundle;

class TranslationController extends Controller
{
    /**
     * @Route("/")
     */
    public function index()
    {
        $RoromixSpreadsheetBundle = new RoromixSpreadsheetBundle();

    //...
    }
}

?>
Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
ABSimon3
  • 23
  • 4

1 Answers1

0

I think for get service in your controller :

dump($this->get('phpspreadsheet'));

Because service name as phpspreadsheet : https://github.com/roromix/SpreadsheetBundle/blob/master/src/Resources/config/services.yml

Gaylord.P
  • 1,539
  • 2
  • 24
  • 54
  • What happened when you tried it? Because in most cases, SF4 does not allow controllers to pull these sorts of services from the container. – Cerad Mar 02 '18 at 16:41
  • I didn't test it, I just read the code :) `RoromixSpreadsheetBundle`are not a service in your bundle. – Gaylord.P Mar 02 '18 at 16:49
  • You're extends of `Controller`, you can use public service without inject :) – Gaylord.P Mar 02 '18 at 16:51