---
title: 'TWIG template engine either "TWIG" or "PHP"'
url: 'https://getgrav.org/forum/support/twig-template-engine-either-twig-or-php-t457'
markdown: 'https://getgrav.org/forum/support/twig-template-engine-either-twig-or-php-t457.md'
date: '2026-06-21'
description: 'Hi, on the website http://symfony.com/doc/current/templating/PHP.html Symphony mentions that TWIG can use two engines for processing templates: TWIG and PHP.'
---

[Support](https://getgrav.org/forum/support)

#  TWIG template engine either "TWIG" or "PHP" 

  Started by Peter Ebbelink 9 years ago · 4 replies · 1846 views    

 [9 years ago](https://getgrav.org/forum/support/twig-template-engine-either-twig-or-php-t457#post-21988 "Permalink") 

Hi,
on the website <http://symfony.com/doc/current/templating/PHP.html> Symphony mentions that TWIG can use two engines for processing templates: TWIG and PHP.
TWIG determines the difference by the extension:
myFile.html.twig is processed by the TWIG engine,
myFile.html.php is processed by the PHP engine.
Can I convince GRAV to obey this convention?
Currently I seem to only be able to use the TWIG engine.
I need to create a template that pulls data from a MySQL database and this seems a more appealing way than writing a TWIG extension.
Anyone has insight on this topic?

Thanx in advance!

Regarz, Peter

 [9 years ago](https://getgrav.org/forum/support/twig-template-engine-either-twig-or-php-t457#post-22106 "Permalink") 

I'm afraid I can't answer your specific question, but why not write a plugin that pulls the data from SQL and then injects that data into the Twig variable space? Your standard Twig template then displays that data. That might be the simplest approach.

 👍 1 

 [9 years ago](https://getgrav.org/forum/support/twig-template-engine-either-twig-or-php-t457#post-22124 "Permalink") 

Thanx for replying PerlKonig.
Jep, I might.
But

1. I'm not that experienced in this field and (the most important)
2. TWIG is said to have a built in mechanisme to switch engines (between TWIG and PHP, depending on the extension (".HTML.TWIG" and ".HTML.PHP")

So, why reinvent the wheel? ..... I just can't find the wheel ....

Cheers, Peter

 [9 years ago](https://getgrav.org/forum/support/twig-template-engine-either-twig-or-php-t457#post-22127 "Permalink") 

I hope someone can answer your question. If you decide to go the other route, here are two plugins that do what I mentioned:

- [Import](https://github.com/Perlkonig/grav-plugin-import) loads files given in the frontmatter and makes the data avaialable to Twig.
- [IPLocate](https://github.com/Perlkonig/grav-plugin-iplocate) runs the visitor's IP address through one or more services and injects the results into Twig.

Good luck!

 [9 years ago](https://getgrav.org/forum/support/twig-template-engine-either-twig-or-php-t457#post-22156 "Permalink") 

Cool Perlkonig!
Thanx for your assistance!

cheers, Peter

[Log in](https://getgrav.org/login?return=%2Fforum%2Fsupport%2Ftwig-template-engine-either-twig-or-php-t457) to reply.

###  Suggested topics

 | Topic | Participants | Replies | Views | Activity |
|---|---|---|---|---|
| [retina images are shown in Admin (but not all of them)](https://getgrav.org/forum/support/retina-images-are-shown-in-admin-but-not-all-of-them-t9504)    [Support](https://getgrav.org/forum/support) · by Anna, 23 hours ago |  | 1 | 32 | [20 hours ago](https://getgrav.org/forum/support/retina-images-are-shown-in-admin-but-not-all-of-them-t9504 "by Anna") |
| [page.date != page.header.date, now my collection sorting is broken (bug? by design?)](https://getgrav.org/forum/support/page-date-page-header-date-now-my-collection-sorting-is-broken-bug-by-design-t9484)    [Support](https://getgrav.org/forum/support) · by Anna, 2 weeks ago |  | 1 | 231 | [2 weeks ago](https://getgrav.org/forum/support/page-date-page-header-date-now-my-collection-sorting-is-broken-bug-by-design-t9484 "by Anna") |
| [it's no possible sign in with email......](https://getgrav.org/forum/support/it-s-no-possible-sign-in-with-email-t9462)    [Support](https://getgrav.org/forum/support) · by webmasterodp, 1 month ago |  | 4 | 362 | [1 month ago](https://getgrav.org/forum/support/it-s-no-possible-sign-in-with-email-t9462 "by webmasterodp") |
| [Site stopped working overnight - 'not writeable' error](https://getgrav.org/forum/support/site-stopped-working-overnight-not-writeable-error-t9445)    [Support](https://getgrav.org/forum/support) · by nwhitfield, 1 month ago |  | 2 | 335 | [1 month ago](https://getgrav.org/forum/support/site-stopped-working-overnight-not-writeable-error-t9445 "by pamtbaau") |
| [MIgrating to 2.0](https://getgrav.org/forum/support/migrating-to-2-0-t9437)    [Support](https://getgrav.org/forum/support) · by stell, 1 month ago |  | 5 | 625 | [1 month ago](https://getgrav.org/forum/support/migrating-to-2-0-t9437 "by stell") |
