tiger-seo / PhpBuiltinServer

Codeception extension for starting and stopping php built-in server
38 stars 35 forks source link

Added option to force usage of router file #21

Open bcole808 opened 9 years ago

bcole808 commented 9 years ago

The Problem

I needed to be able to have all server requests to the php built in server utilize my custom router.php file. This extension has a built in router which sometimes sends requests straight to the servers document root and sometimes sends requests to the specified router.php file.

The Fix

I added an option to allow the developer to configure this extension to always send requests to the specified router file, regardless of the contents of document root.

Works like this:

    config:
        Codeception\Extension\PhpBuiltinServer:
            hostname: localhost
            port: 9000
            documentRoot: src
            startDelay: 1
            router: my_router.php
            alwaysUseRouter: true
tiger-seo commented 9 years ago
        if (file_exists($filePath) && is_file($filePath)) {
            return false; // serve the requested resource as-is.
        } elseif ($userRouter) {
            return $userRouter;
        }

the reason why router is not used is because the requested resource is exists

bcole808 commented 9 years ago

Yes, I understand that is why the router is only used for some requests. My issue is that I need all requests to go to the router, even if the resource exists in the document root directory.