subfission / cas

Simple CAS Authentication for Laravel 5 - 10.
MIT License
151 stars 70 forks source link

how to make it works with laravel 10 ? #123

Closed fdalex closed 4 months ago

fdalex commented 5 months ago

Hi, trying to follow your wiki but I find examples are kinda stranges, like,

**After updating composer, add the ServiceProvider to the providers array in app/config/app.php

'Subfission\Cas\CasServiceProvider',

Shouldnt it be Subfission\Cas\CasServiceProvider::class instead like others providers ? I'm confused. (I'm new to laravel, started to learn with version 9, now coding with laravel 10).

    'providers' => ServiceProvider::defaultProviders()->merge([
        /*
         * Package Service Providers...
         */

        /*
         * Application Service Providers...
         */
        App\Providers\AppServiceProvider::class,
        App\Providers\AuthServiceProvider::class,
        // App\Providers\BroadcastServiceProvider::class,
        App\Providers\EventServiceProvider::class,
        App\Providers\RouteServiceProvider::class,
    ])->toArray(),

Same for Kernel Any help ? :)

dstepe commented 5 months ago

The ::class is a constant where the value is the fully qualified class name. Previous versions of Laravel used the class name as a string in config and other files. Using the constant is the preferred method, however, because IDEs and other tools can correctly resolve and understand the constant, unlike the string value.

Many packages, including this one, were initially developed when the Laravel config used the string version so that's what was documented. Any time you see the use class name as quoted string, you should be able to use the ::class constant instead. Unless it's in a actual string context of course. :)

In your case:

Subfission\Cas\CasServiceProvider::class,

Sorry for the confusion. I'll leave this issue open as a reminder to update the documentation.

fdalex commented 5 months ago

Thanks, looks like I'm on a good way now to make it work. cas()->authenticate() is generating the CAS url. (still some CORS errors but from current API auth system, working on it).

subfission commented 4 months ago

@dstepe thank you for stepping in to help these devs. I updated the wiki to include the new paradigm for Laravel. It's amazing how much Laravel has grown since version 5!