How to write php code in hbs?

I have created a custom layout in a sidecar module "Accounts" and display a simple View "Hello World" on the screen. Now what I want to do is that I want to fetch all the accounts records from the database and display in that custom layout. I know that in order to fetch data you have to use either sugarQuery or sqlQuery. And what I want to know is How can I use php code in hbs template? Thanks in advance!