PHP code example of coly010 / untitled

1. Go to this page and download the library: Download coly010/untitled 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/ */

    

coly010 / untitled example snippets




namespace Application\Pages\About\About_Page;

use Untitled\PageBuilder\Page;
use Application\Pages\About\Routes\About_Route;

class About_Page extends Page {

  public function __construct(){
    parent::__construct();

    $this->AddRoute(new About_Route());
  }

}



namespace Application\Pages\About\Routes\About_Route;

use Untitled\PageBuilder\Route;

class About_Route extends Route {

  public function __construct(){
    parent::__construct();

    $this->Request = "about";
    $this->RenderView = true;
    $this->ViewFilePath = "About/about.html";
  }

  public function RunDataProcess(){}

}


$db = new Database()->Connect();
$db = $db->DB;



namespace Application\DataProcesses;

use Untitled\PageBuilder\DataProcess;

class About_DataProcess extends DataProcess {

  public function __construct(){
    parent::__construct();
  }

  public function RetrieveContent(){
    $this->db->Run("SELECT * FROM content WHERE page = :page", [":page" => "about"]);
    $content = $this->db->Fetch()['content'];
    return $content;
  }

}


public function __construct(){
  parent::__construct();

  $this->Request = "about";
  $this->RenderView = true;
  $this->ViewFilePath = "About/about.html";
  $this->DataProcess = new About_DataProcess();
}

public function RunDataProcess(){
  $this->ViewData = ["content" => $this->DataProcess->RetrieveContent()];
}

Application_Config.php
Database_Config.php
Twig_Config.php



namespace Application\Config;


class Application_Config
{

    public static $PAGES_DIR = "Application/Pages";
    public static $DATA_PROCESSES_DIR = "Application/DataProcesses";
    public static $VIEWS_DIR = "Application/Views";

}



namespace Application\Config;


class Database_Config
{

    /**
     * @var string Database Server host
     */
    public static $HOST = "localhost";

    /**
     * @var string Database name to connect to
     */
    public static $DBNAME = "";

    /**
     * @var string Username for the database
     */
    public static $USER = "";

    /**
     * @var string Password for the associated username
     */
    public static $PASS = "";

}



namespace Application\Config;

class Twig_Config
{

    /**
     * @var string Path to the templates
     */
    public static $TEMPLATE_PATH = "Application/Views";

    /**
     * @var string Path to the cache directory
     */
    public static $CACHE_PATH = "Application/Cache";

}



namespace Application\Pages\Search\Routes;

use Untitled\PageBuilder\Route;
use Application\DataProcess\Search_DataProcess;

class Search_Route extends Route {

  public function __construct(){
    parent::__construct();

    $this->ComplexRoute = true;
    $this->Request = "search/%VAR%"
    $this->RenderView = true;
    $this->ViewFilePath = "Search/results.html";
    $this->DataProcess = new Search_DataProcess();
  }

  public function RunDataProcess(){
    $this->ViewData = ["search_result" => $this->DataProcess->DoSearch($this->Params[0])];
  }

}