Welcome Guest, Not a member yet? Register   Sign In
$routes->match() behavior in 4.4.1
#1
Lightbulb 
(This post was last modified: 09-13-2023, 02:43 AM by joho.)

Does $routes->match() behave differently in 4.4.x?

I have this, and it works for 4.3.x, but seemingly not for 4.4.1:

Code:
use CodeIgniter\Router\RouteCollection;
use App\Controllers\zAdmin;

$routes->setTranslateURIDashes(false);
$routes->set404Override();

$routes->get( '/', [zAdmin::class, 'index'] );

$routes->group( 'zadmin', static function( $routes ) {
    $routes->match( ['get','post'], 'fetchinfo', [zAdmin::class, 'ajax_fetch'] );
    $routes->match( ['get','post'], 'fetchrepoinfo', [zAdmin::class, 'ajax_fetch_repo'] );
    $routes->match( ['get','post'], 'fetchzampnews', [zAdmin::class, 'ajax_fetch_zamp_news'] );
    $routes->match( ['get','post'], 'tagzampnews', [zAdmin::class, 'ajax_tag_zamp_news'] );
    $routes->match( ['get'], 'zamprepo', [zAdmin::class, 'zamprepo'] );
    $routes->match( ['get'], 'zampnews', [zAdmin::class, 'zampnews'] );
    $routes->match( ['get', 'post'], 'create', [zAdmin::class, 'edit'] );
    $routes->match( ['get', 'post'], 'edit/(:segment)', [zAdmin::class, 'edit'] );
    $routes->match( ['get'], '(:segment)', [zAdmin::class, 'view'] );
    $routes->get( '/', [zAdmin::class, 'index'] );
});

"Home" work, i.e. no parameters at all, but anything other than that yields a 404 with messages like "Can't find a route for 'get: 2'" (which I think should have been triggered on the second to last match(). I'm obviously doing something wrong, I just don't know what?


Hmm ... apparently this:

Code:
$routes->group( 'zadmin', static function( $routes )


needed to be this:

Code:
$routes->group( '', static function( $routes )

-joho
Reply
#2

Check the routing table.
$ php spark routes
Reply
#3

(09-13-2023, 03:42 AM)kenjis Wrote: Check the routing table.
$ php spark routes

Yeah, I did that, thanks, and it looked good; until I realized that /zadmin shouldn't be a part of the route. So setting it to '' (empty) worked better Cool

-joho
Reply




Theme © iAndrew 2016 - Forum software by © MyBB