main
Robert 7 hours ago
parent 7092a28400
commit 5fe600cb47
  1. 6
      protected/src/configs/on_footer_banner.php
  2. 5
      protected/src/controllers/app/cookie_ctrl.php
  3. 43
      protected/src/controllers/app/home_ctrl.php
  4. 5
      protected/src/controllers/app/jwt_ctrl.php
  5. 3
      protected/src/controllers/app/protected_ctrl.php
  6. 3
      protected/src/controllers/app/testing_ctrl.php
  7. 36
      protected/src/routes/app/home_routes.php
  8. 4
      protected/src/routes/routes.php

@ -9,8 +9,8 @@ declare(strict_types=1);
*/
namespace Project;
function get_footer(): string {
return '<footer style="
class MyPage {
public const string MyFooter = '<footer style="
background-color: #333;
color: white;
text-align: center;
@ -30,4 +30,6 @@ function get_footer(): string {
</p>
</div>
</footer>';
public const string MyAuthors = 'Robert Strutts, plus ME!';
}

@ -10,7 +10,6 @@ declare(strict_types = 1);
namespace Project\controllers\app;
use \CodeHydrater\base_controller;
use \CodeHydrater\http\response as Response;
use \CodeHydrater\enums\exit_on_dump as endDump;
class cookie_ctrl extends base_controller {
@ -19,7 +18,7 @@ class cookie_ctrl extends base_controller {
\CodeHydrater\security::init_sessions(); // Init Sessions
}
public function save(): Response {
public function save() {
$_SESSION['testing_user'] = "Bob";
$_SESSION['awesome'] = true;
@ -27,7 +26,7 @@ class cookie_ctrl extends base_controller {
return $this->response;
}
public function read(): Response {
public function read() {
dd($_SESSION, endDump::keep_working);
// var_dump($_SESSION['admin'] ?? "");
return $this->response;

@ -11,28 +11,19 @@ namespace Project\controllers\app;
use \CodeHydrater\base_controller;
use \CodeHydrater\enums\view_type as ViewType;
use \CodeHydrater\http\response as Response;
/**
* Description of home_ctrl URL Route: /FOLDER/FILE/METHOD
* /app/home/name_demo
*/
class home_ctrl extends base_controller {
private $footer;
public function init() {
// FROM on_footer_banner.php in the configs folder...
if (function_exists("\Project\get_footer")) {
$this->footer = \Project\get_footer();
} else {
$this->footer = "";
}
// Defined from: on_footer_banner.php in the configs folder...
$this->set_footer_and_authors();
}
public function index(): Response {
$this->html->set_footer($this->footer);
$this->html->set_author("Robert Strutts, plus ME!");
public function index() {
$this->view->set('html', $this->html);
$this->view->set_template('main');
$this->view->include("app/header", ViewType::PHP);
@ -43,7 +34,7 @@ class home_ctrl extends base_controller {
return $this->response;
}
public function name_demo(): Response {
public function name_demo() {
echo $this->footer;
$this->view->set('twig_data', ['name' => "John Doe"]);
@ -53,7 +44,7 @@ class home_ctrl extends base_controller {
return $this->response;
}
public function liquid(): Response {
public function liquid() {
echo $this->footer;
$this->view->set('template_assigns', [
'name' => "James Smith",
@ -65,7 +56,7 @@ class home_ctrl extends base_controller {
return $this->response;
}
public function extra(): Response {
public function extra() {
$loaded = \CodeHydrater\extras_booter::tryToEnableFeature("testing", refresh: true);
if ($loaded === false) {
$content = "Unable to load Feature...";
@ -77,31 +68,11 @@ class home_ctrl extends base_controller {
return $this->response;
}
public function make_hash(): Response {
public function make_hash() {
$content = \CodeHydrater\security::do_password_hash("Hello, World");
$this->response->set_content($content);
return $this->response;
}
/**
* from Routes
*
*/
public function test(int $id): Response {
$content = "The ID for Test Example is # $id";
$this->response->set_content($content);
return $this->response;
}
public function demo(?string $name="Test", ?int $limit=10, ?int $page=1): Response {
$content = "DEMO Name: ". \CodeHydrater\bootstrap\safer_io::p($name);
$content .= "LIMIT = ". $limit;
$content .= "PAGE = ". $page;
$this->response->set_content($content);
return $this->response;
}
}

@ -11,12 +11,11 @@ namespace Project\controllers\app;
use \CodeHydrater\base_controller;
use CodeHydrater\bootstrap\registry as Reg;
use \CodeHydrater\http\response as Response;
use \CodeHydrater\enums\exit_on_dump as endDump;
class jwt_ctrl extends base_controller {
public function index(): Response {
public function index() {
// Payload data (customize as needed)
$payload = [
'iss' => 'your-issuer', // Issuer
@ -36,7 +35,7 @@ class jwt_ctrl extends base_controller {
return $this->response;
}
public function read(array $p): Response {
public function read(array $p) {
$token = $p['token'] ?? false;
if ($token === false) {
echo "Sorry, no token in URL";

@ -10,7 +10,6 @@ declare(strict_types = 1);
namespace Project\controllers\app;
use \CodeHydrater\base_controller;
use \CodeHydrater\http\response as Response;
/**
* Description of protected_ctrl
@ -25,7 +24,7 @@ class protected_ctrl extends base_controller {
\Project\classes\auth_middleware::class
];
public function index(): Response {
public function index() {
$this->response->set_content("Coool!");
return $this->response;
}

@ -10,7 +10,6 @@ declare(strict_types = 1);
namespace Project\controllers\app;
use CodeHydrater\base_controller;
use CodeHydrater\http\response as Response;
/**
* Description of testing_ctrl
@ -34,7 +33,7 @@ class testing_ctrl extends base_controller {
return str_replace('CodeHydrater', '_', $results). "\n<br>";
}
public function count_files(): Response {
public function count_files() {
// Disable on production as you don't want to expose FW info...
// exit(0);

@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
/**
* @author Robert Strutts <Bob_586@Yahoo.com>
* @copyright (c) 2025, Robert Strutts
* @license MIT
*/
namespace Project\routes\app;
use \CodeHydrater\base_controller;
class home_routes extends base_controller {
/**
* from Routes file
*
*/
public function test(int $id) {
$content = "The ID for Test Example is # $id";
$this->response->set_content($content);
return $this->response;
}
public function demo(?string $name="Test", ?int $limit=10, ?int $page=1) {
$content = "DEMO Name: ". \CodeHydrater\bootstrap\safer_io::p($name);
$content .= "LIMIT = ". $limit;
$content .= "PAGE = ". $page;
$this->response->set_content($content);
return $this->response;
}
}

@ -10,8 +10,8 @@ class routes {
public static function get() {
// ::i is a int() shortcut, ::s is a string
Router::get('example/{id::i}', 'Project\controllers\app\home_ctrl@test');
Router::route("demo/{name::s}/{limit::i}?/{page::i}?", "Project\controllers\app\home_ctrl@demo");
Router::get('example/{id::i}', 'Project\routes\app\home_routes@test');
Router::route('demo/{name::s}/{limit::i}?/{page::i}?', 'Project\routes\app\home_routes@demo');
}
}
Loading…
Cancel
Save