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?
            Asked
            
        
        
            Active
            
        
            Viewed 524 times
        
    1 Answers
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
        
- 5,021
- 1
- 36
- 34
 
    
    
        ChristianM
        
- 1,793
- 12
- 23
- 
                    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
