Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[L5.1] config stops config:cache working #466

Closed
xLink opened this issue Jun 15, 2015 · 10 comments
Closed

[L5.1] config stops config:cache working #466

xLink opened this issue Jun 15, 2015 · 10 comments

Comments

@xLink
Copy link

xLink commented Jun 15, 2015

the api config currently has this:

    'auth' => [
        'basic' => function ($app) {
            return new Dingo\Api\Auth\Provider\Basic($app['auth']);
        }
    ],

the closure there will break the config:cache from working, is there anyway you can rework the code to avoid the closure being needed, was thinking something like:

    'auth' => [
        'basic' => 'Dingo\Api\Auth\Provider\Basic',
    ],

then the config:cache will work and and we can still use the speed boost :D

@tymondesigns
Copy link
Contributor

@xLink
Copy link
Author

xLink commented Jun 15, 2015

looks like there is a fix here: efficiently/authority-controller#27 (comment)

will try it when i get home and report back

@tymondesigns
Copy link
Contributor

Yep SuperClosure can be used to serialize it.

@jasonlewis
Copy link
Contributor

I'll look into simplifying the configuration as much as I can. I'm afraid it may mean configuring it in other places though, which is probably less than ideal.

@xLink
Copy link
Author

xLink commented Jun 18, 2015

i had a look locally, it worked without issue, so i created a pull request

@tomschlick
Copy link
Contributor

Following your advice, my config looks like this

image

I get this error when hitting any artisan command / http endpoint afterwards

image

Anyone else seeing this?

@jasonlewis
Copy link
Contributor

I've not used the serializer for config caching so can't give you any advice here.

I still need to look more into this issue. I guess for now if this isn't work don't cache your config. That or do your API related config in a bootstrapping file as everything can be configured on runtime.

Here's how you'd do authentication.

app('Dingo\Api\Auth\Auth')->extend('jwt', function ($app) {
    return new Dingo\Api\Auth\Provider\JWT($app['Tymon\JWTAuth\JWTAuth']);
});

The wiki covers the others.

@astroanu
Copy link

Laravel doesn't use closures in config anymore. you will need to pass a string. Any update on this ?

@jasonlewis
Copy link
Contributor

Hm, I'll see what changes I can make.

I guess most of the more complex keys can be pulled out and simply be set from a provider.

@jasonlewis
Copy link
Contributor

I've gone ahead and removed the ability to use closures and callables in a config file. Docs have been updated to demonstrate the alternative ways of configuring more complex aspects of the package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants