Hey @sturm were you able to figure this out?
Removing Dingo
We have a Laravel API project built back in the Laravel 5 days and was upgraded incrementally to Laravel 8. This week, I'm upgrading it to Laravel 9 with PHP 8.1 and have done so successfully. However, I'd like to also end our dependency on the Dingo API since it's deprecated.
I'd instead use Laravel's built-in API routing, but it looks like it's fairly well-integrated into our app, especially in terms of authentication. Since it appears that we use OAuth2 tokens, I figure I can set up Laravel Passport to be used in place of Dingo. (It seems to be already installed, too.)
One step on this path is to modify our dozens of Controllers that use Dingo. For example, here's a small piece of error output from running PhpStan:
------ ------------------------------------------------------------------------
Line Http/Middleware/CheckAnyAPIPermissionMiddleware.php
------ ------------------------------------------------------------------------
16 Class App\Http\Middleware\CheckAnyAPIPermissionMiddleware uses unknown
trait Dingo\Api\Routing\Helpers.
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
36 Access to an undefined property
App\Http\Middleware\CheckAnyAPIPermissionMiddleware::$auth.
42 Access to an undefined property
App\Http\Middleware\CheckAnyAPIPermissionMiddleware::$response.
44 Access to an undefined property
App\Http\Middleware\CheckAnyAPIPermissionMiddleware::$response.
------ ------------------------------------------------------------------------
So some Dingo-specific properties and methods like $auth, $response, and various things in Helpers must be replaced. I've already done some substitutions like replacing $this->auth->user() with auth()->user(), $this->response->errorForbidden() with response('Forbidden', 403), using throw new ValidationException() in place of Dingo's throw new ValidationHttpException(), etc. However, these simple substitutions don't seem to work. auth()->user() is returning null. And to make matters worse, our weird database saves API users into an api_users table instead of users.
I've also removed some Dingo-specific files, such as app/Providers/PassportDingoProvider.php, config/api.php, etc. I'm unsure if I should translate some of the info within those files to Laravel Passport files. So, as you can see, I'm kinda winging it here.
Are there instructions for properly migrating away from Dingo and replacing it with Laravel's built-in routing and Passport?
Please or to participate in this conversation.