dakota / CakeExcel

A plugin to generate Excel files with CakePHP. Uses the PHPExcel library.
MIT License
22 stars 25 forks source link

Controller class not found #14

Closed Bird87ZA closed 8 years ago

Bird87ZA commented 8 years ago

I have everything set up as per the README file.

I've copied and pasted the config/bootstrap.php and config/routes.php lines. In my AppController.php file I have set up the RequestHandler component as required and I have a default template in Template\Layout\xlsx\default.ctp containing the one line as suggested.

I added the link ($this->Html->link('Excel file', ['_ext' => 'xlsx']) the controller's index.ctp file, and I have a xlsx\index.ctp file in the Template directory. When I load the page, the link is echo'd as localhost\site\example.xlsx where controller is the name of the controller. Clicking on this, it gives me a Controller class Example.xlsx could not be found. error. When I type the URL localhost\site\example\index.xlsx in the address bar, I get Error: Create ExampleController::index.xlsx() in file: src\Controller\ExampleController.php. error.

What am I doing wrong?

josegonzalez commented 8 years ago

@Bird87ZA how did you load the plugin? And can you gist your config/routes.php file?

Bird87ZA commented 8 years ago

Installed it with composer. and then in bootstrap.php I have this line:

Plugin::load('CakeExcel', ['bootstrap' => true, 'routes' => true]);

Bird87ZA commented 8 years ago

https://gist.github.com/Bird87ZA/2cd58b3251e7448d3a405d8684663a23

josegonzalez commented 8 years ago

Move the Router::extensions('xlsx') call to here: https://gist.github.com/Bird87ZA/2cd58b3251e7448d3a405d8684663a23#file-routes-php-L43

Bird87ZA commented 8 years ago

Works now. Thanks! :) Perhaps just add that in the Readme. :)