Skip to content

Commit

Permalink
Updated Packages & More
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianFun123 committed Jul 28, 2022
1 parent 9feb6b6 commit b92e61a
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 16 deletions.
11 changes: 6 additions & 5 deletions cli
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ chdir(".");
if (file_exists("vendor/autoload.php"))
require_once "vendor/autoload.php";

$app = (new App)
->setInCLI(true) // Deactivates the web stuff
->start(Environment::fromCurrent());
$cli = new CLIBootstrapper($argv);

(new CLIBootstrapper($argv))
->register(new CustomCLI())
$app = (new App)->setInCLI(true);
$app->initCLI($cli);
$app->start(Environment::fromCurrent());

$cli
->addFrameworkHandlers($app)
->run();
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "interaapps/ulole-framework",
"version": "3.3.3",
"version": "3.3.4",
"require": {
"interaapps/ulole": "=3.1.6"
"interaapps/ulole": "=3.2.0"
},
"autoload": {
"psr-4": {
Expand Down
22 changes: 15 additions & 7 deletions src/main/com/example/myproject/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

use com\example\myproject\controller\SecondTestController;
use com\example\myproject\controller\TestController;
use com\example\myproject\helper\cli\CustomCLI;
use com\example\myproject\middlewares\ExampleMiddleware;
use com\example\myproject\model\User;
use de\interaapps\ulole\core\cli\CLIBootstrapper;
use de\interaapps\ulole\core\jobs\JobModel;
use de\interaapps\ulole\orm\UloleORM;
use de\interaapps\ulole\core\Environment;
Expand Down Expand Up @@ -48,13 +51,14 @@ public function init(): void {
public function run(): void {
$router = $this->getRouter();

$router
->get("/a/{test}", function (Request $req, Response $res, string $test = null): array {
// Automatically turns this into JSON
return [
"Yep" => $test
];
});
$router->middleware("example", new ExampleMiddleware());

$router->get("/a/{test}", function (Request $req, Response $res, string $test = null): array {
// Automatically turns this into JSON
return [
"Yep" => $test
];
});

$router->notFound(function () {
return view("error", ["error" => "Page not found"]);
Expand All @@ -67,6 +71,10 @@ public function run(): void {
);
}

public function initCLI(CLIBootstrapper $cli): void {
$cli->register(new CustomCLI());
}

public static function main(Environment $environment) {
(new self())->start($environment);
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/com/example/myproject/controller/TestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use de\interaapps\ulole\orm\Query;
use de\interaapps\ulole\router\attributes\Controller;
use de\interaapps\ulole\router\attributes\Route;
use de\interaapps\ulole\router\attributes\With;
use de\interaapps\ulole\router\Request;
use de\interaapps\ulole\router\Response;

Expand All @@ -19,6 +20,7 @@ public static function index(Request $req, Response $res): string {
}

#[Route("/user/{i+:userId}", method: "GET")]
#[With("example")]
public static function getUser(Request $req, Response $res, int $userId): string {
$user = User::table()
->where("id", $userId)
Expand Down
13 changes: 13 additions & 0 deletions src/main/com/example/myproject/middlewares/ExampleMiddleware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
namespace com\example\myproject\middlewares;

use de\interaapps\ulole\router\interfaces\Middleware;
use de\interaapps\ulole\router\Request;
use de\interaapps\ulole\router\Response;

class ExampleMiddleware implements Middleware {
public function handle(Request $req, Response $res) : mixed {
echo "<!-- Hello from Middleware! -->\n";
return null;
}
}
4 changes: 2 additions & 2 deletions uppm.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ulole-framework",
"version": "3.3.3",
"version": "3.3.4",
"repositories": [],
"run": {
"cli": "cli"
Expand All @@ -21,7 +21,7 @@
"routerFile": "index.php"
},
"modules": {
"ulole-core": "3.1.6"
"ulole-core": "3.2.0"
},
"namespaceBindings": {},
"initScripts": []
Expand Down

0 comments on commit b92e61a

Please sign in to comment.