Welcome Guest, Not a member yet? Register   Sign In
DIFINING A ROUTE
#1

I would like to know which one is the best practice to define a route in CodeIgniter 4:
PHP Code:
$routes->post('registration', [ApiVendorAuthController::class, 'registerVendor']);
$routes->post('registration''ApiVendorAuthController::registerVendor', ['namespace' => 'App\Controllers\Api\Vendor']); 
Learning Codeigniter 
Reply
#2

(This post was last modified: 02-27-2024, 03:40 AM by InsiteFX.)

CodeIgniter 4 User Guide - URI Routing - Assigning Namespace

I only add the namespace on my Routes that are in a Routes Group.

The first one will prepend the namespace, where the second one only applies it to the method.

The above link will explain it for you.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(02-27-2024, 03:33 AM)InsiteFX Wrote: CodeIgniter 4 User Guide - URI Routing - Assigning Namespace

Thank you for the reply, I want to know which is the best way?
Learning Codeigniter 
Reply
#4

It is up to you, but I use the first one on regular Routes and the second one on my Route Groups.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB