interaapps / ulole-framework
There is no license information available for the latest version (3.3.4) of this package.
3.3.4
2022-07-28 15:25 UTC
Requires
- interaapps/ulole: =3.2.0
README
The ulole-framework is a highly customizable PHP-Framework.
Based on
Create Project
# With UPPM uppm create myapp interaapps/ulole-framework # Or with Composer composer create-project interaapps/ulole-framework myapp
Example
app\App.php
<?php 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() ]); }); } }
Cli
Serve
php cli serve
A simple serve command (Runs on localhost:8000)
Repl:
$ 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 :)"
Multiline works with a \
$ php cli repl >>> function test(){\ ... echo "Hello world :)";\ ... } null >>> test() Hello world :)
We will also check for a [
, (
, {
, ,
>>> [ ... "adsfasfd"=>31412341234, ... "asfdasfd"=>"asfasdfasd"\ ... ] [ "adsfasfd": 31412341234 "asfdasfd": "asfasdfasd" ]
Create:
There is a helpful tool for creating models and other stuff.
$ php cli create:model Test
Migration
Migration up
$ php cli migrate:up Migrated resources\migrations\migration_220511_000000_create_users
Migration down
$ php cli migrate:down (how many versions down, optionak) Downgraded resources\migrations\migration_220511_000000_create_users
Migration status
$ php cli migrate:status model | migrated | version migration_201122_001143_create_user | YES | 1
DB
This is a tool to just walk around the database and create some sql-queries.
Extra
Using other template-engine
Example: blade
app/helper/helper.php
// composer require jenssegers\blade use Jenssegers\Blade\Blade; $blade = new Blade("resources/views", "cache/views"); function view($view, $vars=[]) { global $blade; return $blade->render($view, $vars); }