Search code examples
phpexcellaravelxdebug

Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '256' frames


Trying to generate an Excel using an pre-existing template, and got the xdebug error I am using the exact same code for other project, and everything its ok

public function excel($dt){
        $path = time() . '.xlsx';

        $file = public_path('exports/TEMPLATES/monitorizacao_2023.xlsx');
    

        $data = [        
            'products' => [
                [
                    'name' => 'Product #1',
                    'price' => 989,
                    'qty' => 1,
                    'date' => new \DateTime('2022-03-30'),
                ],
                [
                    'name' => 'Product #2',
                    'price' => 1015.14,
                    'qty' => 2,
                    'date' => new \DateTime('2022-03-31'),
                ],
            ],
        ];

        // Save to the file
        (new \AnourValar\Office\SheetsService())
        ->generate(
            $file, // template filename
            $data // markers
        )
        ->saveAs(
            'generated_document.xlsx', // filename
            \AnourValar\Office\Format::Xlsx // save format
        );
    }

my template has one cell waiting for the array:

Cell A1

[products.name]

From where am I getting this error? If I run with this code, it works:

$data = [
    ['William', 3000],
    ['James', 4000],
    ['Sveta', 5000],
];

// Save as XLSX (Excel)
(new \AnourValar\Office\GridService())
    ->generate(
        ['Name', 'Sales'], // headers
        $data // data
    )
    ->saveAs('generated_grid.xlsx');

Nothing helped me in previous research of similar problems. I run the other project on the same pc and the export of any excel from that project works. In this, even the simplest example gives error


Solution

  • Look for the excel. It was really a problem from the template as I said at the time. Sorry for late answer