vlucas / bulletphp

A resource-oriented micro PHP framework
http://bulletphp.com
BSD 3-Clause "New" or "Revised" License
418 stars 50 forks source link

$app->subdomain catch all #57

Closed sam2332 closed 10 years ago

sam2332 commented 10 years ago

is there some code i can use to make it so my users get a subdomain on my server? like subdomain param or something?

vlucas commented 10 years ago

There currently is not, but you could do a manual if statement, like:

$app->subdomain('www', function($request) {
    // main marketing site
});

if (!in_array($request->subdomain(), [false, 'www', 'admin']) {
    $app->path('/', function($request) {
        select_user_by_subdomain_here($request->subdomain());
        // etc...
    }
}

That's the advantage of using routes directly in the code instead of a routing config file - you basically get unlimited flexibility, and can use plain PHP wherever you want to handle flow control.

sam2332 commented 10 years ago

wonderful!