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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to return a simple .php webpage?

Luamnoxu opened this issue · comments

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.

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

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