artkonekt / concord

Laravel extension for building modular applications where modules are decoupled, re-usable and easily customizable
MIT License
211 stars 13 forks source link

Target class [concord] does not exist #9

Closed sornss closed 4 years ago

sornss commented 4 years ago

Hello,

New guy here, I have tried to setup an external module(Avendor/Demo) with Laravel 6. and Concord 1.4. with the below error when specify providers' model to UserProxy::modelClass() in the config file auth.php.

`$ composer dump-autoload Generating optimized autoload files

Illuminate\Foundation\ComposerScripts::postAutoloadDump @php artisan package:discover --ansi In Container.php line 805:
Target class [concord] does not exist.
In Container.php line 803: Class concord does not exist
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1`

The simple repo is at https://github.com/sornss/laravel_concord_demo.

Can you please let me know the reason or any help?

Thanks in advance.

fulopattila122 commented 4 years ago

Proxies should only be used within your library and not within the application1, that includes the app config as well.

1: See Concord Proxies.

Solution 1

Use the model class instead of the proxy on line 72 in auth.php:

    'providers' => [
        'users' => [
            'driver' => 'eloquent',
            //'model' => App\User::class,
            'model' => \Avendor\Demo\Models\User::class,
        ],

Solution 2

Another approach is to keep the original App\User in auth.php but modify the class to extend your user model:

// app/User.php
namespace App;

class User extends Avendor\Demo\Models\User {}

We, at artkonekt typically use the second solution when building on top of AppShell's extended user model.

sornss commented 4 years ago

Thank you again, Attila, for the possible solutions.