1

With the default config, PHP's built-in server treats .phtml files as static resources. Is there any way to make it process them as regular .php scripts?

NotGaeL
  • 7,842
  • 3
  • 35
  • 64

1 Answers1

3

With a router script you should be able to check for phtml and then just include the file.

<?php
if (preg_match('/\.(?:php|phtml)$/', $_SERVER["REQUEST_URI"])) {
    require('./' . $_SERVER["REQUEST_URI"]);
    return;
}
return false;

http://php.net/manual/en/features.commandline.webserver.php#example-405

Richard Ayotte
  • 4,671
  • 1
  • 30
  • 33
ChristianM
  • 1,716
  • 12
  • 20
  • This was so obvious! I had already figured out using a router to check for .phtml, but got stuck on how to tell the interpreter to process the file. I am a little embarrassed I didn't realize right away a simple include would do. Thanks for getting me out of it :-) – NotGaeL Mar 08 '15 at 09:17
  • At first I was in the same trap, but then suddenly it dawned on me that this is a php file, so I can do everything. – ChristianM Mar 09 '15 at 10:07