Search code examples
templatescakephptemplate-engineflat-file

Where to store flat files in CakePHP?


I am building an application that allows a user to browse html templates. The html template will be displayed in a preview area (source code will be obfuscated), and although the template will contain inline CSS/JS, there will also be the odd linked image asset.

For this reason, I thought it might be best for me to just store them as a library of folders, and retrieve the flat file from my server for display, as opposed to storing the HTML in the database and having to organise the external assets too.

My question is: Where in the CakePHP directory structure, is the best home for these files? I'd rather keep them above the webroot, and I'm thinking View.

Any ideas? Thanks.


Solution

  • I would suggest that you keep all the out-of-cakephp-framework related files, stored under the webroot.

    My suggestion is the following directory structure for saving the html template as well as the css and js related files.

    /webroot/files/templates/<template-project-name>/<the-actual-file>.html

    Any external css, would then be under /webroot/css/templates/<template-project-name>/<the-actual-css>.css

    And the JS libraries would be under /webroot/js/templates/<template-project-name>/<the-actual-js>.js

    Use a seperate layout file (call it preview_layout.ctp) which simply renders the template file as it is.

    Hope it helps