CodeIgniter Forums
set404Override and debug toolbar - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31)
+--- Thread: set404Override and debug toolbar (/showthread.php?tid=80560)



set404Override and debug toolbar - mavelo - 11-16-2021

Anyone else able to get the debug toolbar to show on 404 overrides?

$routes->set404Override('App\Foo::bar');

Debug toolbar shows on every page in 'development' environment EXCEPT the App\Foo::bar override

Note: Toolbar is displayed when accessing the same route via the /foo/bar in the browser.

CI_ENVIRONMENT and CI_DEBUG at Foo::bar echo 'development' and 'true' as expected.

Even tried passing debug to view('foo_bar', $data, ['debug' => true]) with no change.

Running out of ideas, sans modifying core files, which shouldn't be necessary.

CI Version: 4.1.3

Thoughts?


RE: set404Override and debug toolbar - mavelo - 11-22-2021

Worth noting that HTML debug comments like <!-- DEBUG-VIEW START 5 APPPATH/Views/bar.php --> appear in source, but the toolbar script and style are not injected at <head>


RE: set404Override and debug toolbar - kenjis - 11-22-2021

404 override does not show debug toolbar.
What do you need on 404 page?


RE: set404Override and debug toolbar - mavelo - 11-23-2021

The site uses set404Override to route unmatched URI's to a controller/method thereby facilitating domain.com/username lookups.
  • If the username is not found, we display the 404 view
  • otherwise we show the matching user's profile.
If we route "/(:any)" to the same controller method, the debug toolbar is displayed, but it breaks automatic routing.

set404Override is a better solution for our needs, if not for the inability to show the debug toolbar in the "development" environment.

note: we attempted redirecting when a matching profile was found, but that doesn't seem to function normally when attempted within the override's method.


RE: set404Override and debug toolbar - mavelo - 12-02-2021

We ended up using
Code:
header("Location: "/profile/{$username}", true 302); exit;
upon username match.

Would be nice if we could use
Code:
return redirect()->to("/profile/{$username}")
as in other areas, but that is not available in the 404 override controller/method.

Note: Added to config/routes.php to support the above code
Code:
$routes->get('profile/(:segment)', 'Profile::view/$1');