Search code examples
phpcakephpcakephp-3.xcakephp-3.4

CakePHP 3 Serve Files From Plugin Webroot


I am under the impression that any files placed in the webroot/ folder of a plugin in CakePHP 3 should be served automagically. However, I have not been able to get a file to be served from that folder...

I have created an example project

https://github.com/CakePHPKitchen/CakePHP-Plugin-Webroot-Issue

In the example project, I have baked a plugin named Elite and inside the plugins/Elite/src/webroot I have placed a text file named bingo.txt

To reproduce the issue

My Question is, how do I retrieve bingo.txt?

Do I have to set a setting somewhere to enable that webroot folder?


Solution

  • Make sure the plugin is loaded in your config/bootstrap.php

    Plugin::load('Elite');
    

    Then link to the webroot of the plugin with localhost:8675/elite/bingo.txt