PHP code example of divengine / ways

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

    

divengine / ways example snippets







use divengine\ways;

ways::listen("get://home", function ($data) {
    echo "Hello {$data['user']}";
}, "home");

ways::hook(DIV_WAYS_BEFORE_RUN, "home", function ($data) {
    $data['user'] = "Peter";
    return $data;
});

$data = ways::bootstrap("_url", "home");



#id = home
#listen = /home

class Home
{
    public static function Run()
    {
        echo "Hello world";
    }

    public static function About()
    {
        echo "About us";
    }

    #listen@Contact = get://contact
    public static function Contact()
    {
        echo "Contact us";
    }
}



use divengine\ways;

ways::register("app/control/Home.php");
ways::listen("/about", "home@About");

ways::bootstrap("_url", "home");



use divengine\ways;

ways::rule("is-admin-section", function ($data, $args) {
    return $args["section"] === "admin";
});

ways::listen("/{section}/login", function () {
    echo "admin login";
}, [
    ways::PROPERTY_RULES => ["is-admin-section"],
]);



use divengine\ways;

ways::listen("/hello/{name}", function ($data = [], $args = []) {
    echo "Hello {$args['name']}\n";
});

ways::bootstrap();
bash
php one_script.php hello Peter