Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter 4.3.3 auto routing improved
#1

(This post was last modified: 04-06-2023, 06:50 AM by Corsari.)

Hello to all the community

searching in the forum I have found one post regarding the Auto Routing Improved, but it has not been useful for me

so here I kindly ask some help

I tried to follow both the CI 4.3.3 guide and also that post, but sorry for my limits, I didn't succeeded with Auto Routing Improved

- Routes.php : changed
Code:
$routes->setAutoRoute(true);

- Feature.php : changed
Code:
public bool $autoRoutesImproved = true;


then I have created two dummy

Controller: /Controllers/Admin/Users.php
View: /Views/admin/userslist.php


what makes me crazy is that if I set Feature.php to false ... what follows , works fine


this is the Users.php dummy controller
PHP Code:
<?php

namespace App\Controllers\Admin;
use 
App\Controllers\BaseController;

class 
Users extends BaseController
{
    public function browse()
    {
        return view('admin/userslist');
    }



useless to say that the dummy userslist.php view just shows a dummy "hello world"

if I browse to /ci-app.box/admin/users/browse I get 404 "Controller or its method is not found: \App\Controllers\Admin\Users::getBrowse"

Instead if I set Feature.php --> $autoRoutesImproved = false;  mean using Auto Routing Legacy, it works fine

-  -  -  -

Can you kindly give some instructions on how it is supposed to work auto routing improved? Thank you

When and why to prefer it against manually set all the routes in Routes.php leaving all the auto routing features off/false

Thank you for any gentle clarification help and hint

R.
Reply
#2

See https://codeigniter4.github.io/CodeIgnit...g-improved
Reply
#3

(04-06-2023, 06:07 AM)Corsari Wrote: When and why to prefer it against manually set all the routes in Routes.php leaving all the auto routing features off/false

Auto-Routing Legacy is used when you upgrade from CI3 and it is difficult to use other routing systems.
In short it is only for backward compatibility.

Auto-Routing Legacy is a legacy system and dangerous, but if you don't use Controller Filters (including CSRF protection) at all, the risk is low. When you use it, use it carefully not to create vulnerabilities.

Auto-Routing Improved is used when you don't want to register all routes.
Reply
#4

(This post was last modified: 04-07-2023, 11:59 AM by Corsari.)

Hello
thank you for the reply but it didn't helped :-)

I asked why I can't succeed to have it working in my dummy minimal test , see code above, thank you

I'm using CI 4.3.3 but it looks working only auto routing legacy

thank you for any kind hint
Reply
#5

Read the documentation carefully:
https://codeigniter4.github.io/CodeIgnit...g-improved
It is a complete new auto routing, not the legacy auto routing.

The CI4 is very well documented. I always recommend you read the User Guide.

If you don't know HTTP well, read also https://codeigniter4.github.io/CodeIgnit.../http.html
Reply
#6

(This post was last modified: 04-08-2023, 01:03 AM by Corsari.)

:-)))))

unless you haven't modified/integrated the guide tonight, here
https://codeigniter.com/user_guide/incom...g-improved

I must excuse myself , since it was "too much in foreground to see it" that ptefix LOL

Now that I have "noticed" it, it's easy to get the mean

P.S. together with "build your first application"
in the user guide

I would kindly suggest to provide a second tiny tutorial
"Build your first application with Shield authentication"

I think it might make some sense

What is your kind opinion about this?

E.g. the self news tutorial with authentication to allow posting news

With the occasion I wish a great Easter to you and to all the users with all the persons you care

I mean
Every app dealing with a database has a section where data are added
So authentication is not an "optional", instead it is implicit to have it in the structure
for this simple reason that second tutorial makes lot of sense
My personal opinion :-)
Reply




Theme © iAndrew 2016 - Forum software by © MyBB