spatie/laravel-settings

Documentation confusing

OvalMedia opened this issue · 3 comments

Trying to follow the documentation I stumbled upon https://github.com/spatie/laravel-settings#usage
It says to create a GeneralSettings class that extends Settings. But you don't mention where to create this class and what Settings class it extends from. I figured it must be Spatie\LaravelSettings\Settings but nonetheless, the documentation is lacking clarity here.

Trying to follow the documentation I stumbled upon https://github.com/spatie/laravel-settings#usage It says to create a GeneralSettings class that extends Settings. But you don't mention where to create this class and what Settings class it extends from. I figured it must be Spatie\LaravelSettings\Settings but nonetheless, the documentation is lacking clarity here.

Hi,
Where to create the Class? You can create it anywhere you want just keep in mind to register the class in config/settings.php ...

    /*
     * Each settings class used in your application must be registered, you can
     * put them (manually) here.
     */
    'settings' => [

    ],

If you don't want to register every class, you can simply keep the array empty and change the auto_discover_settings directive bellow.

    /*
     * The package will look for settings in these paths and automatically
     * register them.
     */
    'auto_discover_settings' => [
        app()->path('example/path'),
    ],

That is useful information and should be put into the docs.

In my opinion the docs aren't confusing, you're IDE should support you with importing the Settings class, that being said it is maybe a bit of a struggle for new programmers so I've added a single import statement within the docs to make that clear.

As for where to store your settings classes as @hamzaelmaghari, you're free to do so anywhere within your application. The docs are also describe how to point the package to these settings classes or to use auto discovery. I don't think we should tell developers where to put their classes because there are a lot of valid different styles to structure your app. As with almost any class in Laravel, you can put it everywhere due to autoloading.