PHP code example of interaapps / ulole-framework

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

    

interaapps / ulole-framework example snippets



namespace com\example\myproject;

use com\example\myproject\model\User;
use de\interaapps\ulole\orm\UloleORM;
use de\interaapps\ulole\core\Environment;
use de\interaapps\ulole\core\WebApplication;
use de\interaapps\ulole\core\traits\Singleton;

class App extends WebApplication {
    
    use Singleton;

    public static function main(Environment $environment){    
        self::setInstance( (new self())->start($environment) );
    }

    public function init() : void {
        $this->getConfig()
            ->loadENVFile(".env"); 
            
        // A ulole-framework helper for UloleORM::database("main", new Database(...))
        $this->initDatabase(/*Config prefix*/ "database", "main");
        UloleORM::register(User::class);
    }

    public function run() : void {
        $this->getRouter()
            ->get("/user/{i+:userId}", function($req, $res, int $userId){
                $res->json([
                    "user" => User::table()->where("id", $userId)->get()
                ]);
            });
    }
}

// composer ers\Blade\Blade;

$blade = new Blade("resources/views", "cache/views");

function view($view, $vars=[]) {
    global $blade;
    return $blade->render($view, $vars);
}
bash
php cli serve

$ php cli repl
>>> ["Hello"=>"World",  "Yep" => 1337.1945, "Wait, what?" => null, "Am I allowed to eat chicken?" => true,  "Am I allowed to eat wasps?" => false, "Show me what I am allowed to" => [  "Doing nothing", true,  false, null, 31423 ], "give me user" => \app\model\User::table()->get() ]
...
>>> echo "Hello world :)"
bash
$ php cli repl
>>> function test(){\
...   echo "Hello world :)";\
... }

null
>>> test()
Hello world :)

$ php cli create:model Test
bash
$ php cli migrate:up
Migrated resources\migrations\migration_220511_000000_create_users
bash
$ php cli migrate:down (how many versions down, optionak)
Downgraded resources\migrations\migration_220511_000000_create_users