Welcome Guest, Not a member yet? Register   Sign In
controller redirect to method fails
#1

Greetings,  So far I like the concepts and implementation of CI4 - great job!  
However, I can't get the CI3 redirect equivalents to work in CI4.  I'm using the CI4 Beta 4.0.0 - 1, composer installed.

Desired function: Controller needs to pass control to another controller (or method, module, service, etc).  
Purpose: I created a login module because I have 4 applications using similar code.  I will use routes to return control, and encrypted cookies for validations. BUT, perhaps there may be a bug somewhere.  The code below seems too simple to fail.
Huh
Minimalist failing code:
- I added the route: $routes->get('/(:any)', 'Home::$1');
- Modified the canned Home controller to add a dummy method
- Directly calling http://localhost/dummy works just fine.
- redirect ('dummy'); fails, as do all derivative approaches like: route_to('dummy'), header ("location: dummy"); specifying namespaces and home controller ("app\home\dummy"), etc. all fail...

Code follows.  Help anyone??

config/routes:  $routes->get('/(:any)', 'Home::$1');  (and also tried ...->add and other hacks to no avail)

<?php namespace App\Controllers;
use CodeIgniter\Controller;
class Home extends Controller {

public function index() {
  redirect ("dummy");
  echo "didn't route.";
  //return view('welcome_message');
}

public function dummy() {
 echo "Dummy route.";
}
}

- Thanks
Reply


Messages In This Thread
controller redirect to method fails - by devops - 03-12-2019, 08:25 AM



Theme © iAndrew 2016 - Forum software by © MyBB