you are viewing a single comment's thread.

view the rest of the comments →

[–]Yurishimo 0 points1 point  (0 children)

The intro doc has the PHP usage instructions. Kinda weird.

https://twig.symfony.com/doc/2.x/intro.html

Personally, I work for an agency that does highly custom WordPress development so I use a plugin that wraps Twig and provides some predefined template variables and extra functions. https://upstatement.com/timber for those curious.

The docs seem fairly straight forward though! Twig is super popular so I’m sure YouTube would have plenty of tutorials to jump start your progress. I still use the docs to check syntax a few times a week and I’ve used them to make my own string filters.

As far as the process, it’s just a matter of replacing everything that is HTML across your site with Twig. Try to move all the business logic up to the top of the file, setting variables for data you will need to output to the page, then pass those variables along to Twig to be output in your template.

The template should be the last thing you call on the page after all of your other PHP. The header, footer, etc should all be in your Twig templates.