First of all, we need to setup our
.htaccess file. See Re-routing to index.
To create a hello world project with Leaf, you simply need to initialise Leaf's Router(Leaf)
Leaf simply takes all requests coming into the application and handles them based on rules you define. Enough talk, let's get dirty.
That's all. It's this simple
Since Leaf doesn't restrict you from using your default PHP, you can use
echo to output HTML code, like this:
Though this method works, it is not recommended since the default ouput type for Leaf is
JSON, for this reason,
Leaf has prepared a Response object with a bunch of handy methods(view Response for more info)
This Response object contains a couple of methods for handling HTML properly with the right headers...let's take a look
This method simply renders any html passed into it with a content-type of
HTML Code"); }); $leaf->run();
This method simply displays an already created html/PHP page with the appropriate content type. This method is especially suited to server side routing.
Next StepsSimple Routing