PHP code example of programster / abstract-view

1. Go to this page and download the library: Download programster/abstract-view library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

programster / abstract-view example snippets



use Programster\AbstractView\AbstractView;

class ViewHtmlShell extends AbstractView
{
    public function __construct(
        private readonly string $body,
        private readonly string $title = "My Site"
    ) 
    {
    }

    protected function renderContent()
    {


use Programster\AbstractView\AbstractView;

class ViewWelcomeMessage extends AbstractView
{
    protected function renderContent()
    {


class HomeController
{
    public function showHomePage()
    {
        $homePageBody = new ViewWelcomeMessage();
        $page = new ViewHtmlShell($homePageBody, "Welcome!");
        print $page; // print or add the page to a response object.
    }
}