skipperbent / simple-php-router

Simple, fast and yet powerful PHP router that is easy to get integrated and in any project. Heavily inspired by the way Laravel handles routing, with both simplicity and expand-ability in mind.
654 stars 123 forks source link

How to return a simple .php webpage? #634

Closed Luamnoxu closed 1 year ago

Luamnoxu commented 1 year ago

I apologize if this has been asked before but having looked through the issues the only one i found is from 2019 with no description, replies or anything else.

How would you go about rendering a regular .php/.html file with this router? The Documentation only talks about more advanced things, which are all not really what Im looking for. (At this point Im not even sure if this router is designed to do such simple things haha)

Say for example I have /page1/file.php, how would I go about displaying it? Im aware this is Laravel inspired however I dont have Blade in my project so returning view() isn ta thing

I do apologize if I overlooked something.

DeveloperMarius commented 1 year ago

Hey, you can always just use require 'file.php'; in the response function for a route if you like.

Example:

SimpleRouter::get('/page1/file', function(){
     require __DIR__ . '/../../file.php';
});

~ Marius

Luamnoxu commented 1 year ago

Perfect!!! Thats exactly what I was looking for, thank you