PHP code example of webdevlabs / phreak

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

    

webdevlabs / phreak example snippets



use App\Controllers\Front;

$router->group([
        'prefix'=>'profile', 
        'before'=>'auth'
    ], 
    function ($router) {
        $router->controller('/', 'App\Controllers\Account\Profile');    
    });

    public function postComment () 
    {
        $input  = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
        $val = new \System\Validation($input);
        $val->addRule('name', 'Empty name field', ['ost ok';
        } else {
            $this->template->assign('errors',$val->getErrors());
            $this->template->display("errors.tpl");
        }        
    }



namespace App\Controllers;

use System\Template;
use System\Language;

class Front
{
    private $template;
    private $language;

    public function __construct (Template $template, Language $language) 
    {
        $this->template = $template;
        $this->language = $language;
    }

   public function getIndex()
    {
        $this->template->assign('title', 'Phreak!');
        $this->template->assign('languages', $this->language->available_languages);  
        $this->template->display('layout.tpl');
    }    
}

use System\Event;
class ... {
    public function __construct (Event $event) 
    {
        $this->event = $event;
        $this->event->bind('someEventName', function () { echo "stay foolish"; });
    }
    public function getSome () {
        $this->event->trigger('someEventName');
    }
}

php console.php SomeController