# Render a php file without a template system

**URL:** <https://discourse.slimframework.com/t/render-a-php-file-without-a-template-system/1173>\
**Category:** Questions\
**Created:** [February 22, 2017, 10:06pm UTC](https://discourse.slimframework.com/t/render-a-php-file-without-a-template-system/1173 "2017-02-22T22:06:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![brakkar](https://avatars.discourse-cdn.com/v4/letter/b/b9bd4f/32.png) [@brakkar](https://discourse.slimframework.com/u/brakkar)\
**Post date:** [February 22, 2017, 10:06pm UTC](https://discourse.slimframework.com/t/render-a-php-file-without-a-template-system/1173/1 "2017-02-22T22:06:55Z")

</div>

Hello,  
what’s the best way to render a regular php file without installing a template system in slim ?  
Should I just use php ‘include’ ?

---

<div class="post-metadata">

**Author:** ![TheLobos](https://avatars.discourse-cdn.com/v4/letter/t/e9bcb4/32.png) [@TheLobos](https://discourse.slimframework.com/u/TheLobos)\
**Post date:** [February 22, 2017, 11:30pm UTC](https://discourse.slimframework.com/t/render-a-php-file-without-a-template-system/1173/2 "2017-02-22T23:30:37Z")

</div>

You could just include files, but that is a bad idea. A better approach would be to create namespaced classes for your templates which then either

1. Read a HTML file based on some parameter and return it

or

1. Implement a function which returns HTML

I would view both these approaches as sub-optimal; unless you have very good reasons, there really is no reason not to use a template engine these days.

---

<div class="post-metadata">

**Author:** ![brakkar](https://avatars.discourse-cdn.com/v4/letter/b/b9bd4f/32.png) [@brakkar](https://discourse.slimframework.com/u/brakkar)\
**Post date:** [February 22, 2017, 11:42pm UTC](https://discourse.slimframework.com/t/render-a-php-file-without-a-template-system/1173/3 "2017-02-22T23:42:07Z")

</div>

thanks for your answer.  
Do you know if it is possible to indicate multiple template directories when using the PHP-view template system ?  
I couldn’t see examples with this renderer.

---

<div class="post-metadata">

**Author:** ![llvdl](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/llvdl/32/78_2.png) [@llvdl](https://discourse.slimframework.com/u/llvdl)\
**Post date:** [February 24, 2017, 9:58pm UTC](https://discourse.slimframework.com/t/render-a-php-file-without-a-template-system/1173/4 "2017-02-24T21:58:54Z")

</div>

I don’t think you can set multiple template directories for one renderer, although you can alter the template path for a given renderer using `setTemplatePath`.

If you want to place templates in separate folders, you can use subfolders. When the `PhpRenderer::render` is called for the template `users/index.phtml`, it will look for `index.phtml` in the `users` subfolder of the template path.

Another option would be to create multiple renderers, each with its own templatePath.
