Preface
Hello World
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.
index.php
That's all. It's this simple
Rendering HTML
Basic HTML
Since Leaf doesn't restrict you from using your default PHP, you can use echo
to output HTML code, like this:
Hello World
";
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
RenderMarkup()
This method simply renders any html passed into it with a content-type of text/html
HTML Code
"); }); $leaf->run();renderHtml()
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 Steps
Simple RoutingResponse
Request
Database