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

Binding Resolution Exception #34

Closed
pauly4it opened this issue Jul 1, 2014 · 6 comments
Closed

Binding Resolution Exception #34

pauly4it opened this issue Jul 1, 2014 · 6 comments

Comments

@pauly4it
Copy link

pauly4it commented Jul 1, 2014

I added the three routes mentioned to my routes.php file, added the service provider to app.php, and added the 2 aliases to app.php as well.

When I try to POST to the auth route, however, I get:

Illuminate \ Container \ BindingResolutionException
Target [Tappleby\AuthToken\AuthTokenProviderInterface] is not instantiable.

Is there another piece of code I'm missing somewhere?

Thanks,
Paul

@pauly4it
Copy link
Author

pauly4it commented Jul 2, 2014

I'm not sure if this is related, but if I try to use my own auth route and use this add-on to create a public token, I get the error:

ReflectionException
Class tappleby.auth.token does not exist

My auth route in routes.php:

Route::post('/auth', 'AuthController@login')->before('auth.basic');

In login function of AuthController.php I have:

if (Auth::check())
{
    $authToken = AuthToken::create(Auth::user());
    $publicToken = AuthToken::publicToken($authToken);
}
return Response::json(array(
    'user' => Auth::user(),
    'auth_token' => $publicToken
    ));

@tappleby
Copy link
Owner

tappleby commented Jul 2, 2014

Hrm, it looks like the service provider isnt getting called properly.

I wasnt able to reproduce the error, I followed the steps in the readme with a fresh project and everything ran fine.

@pauly4it
Copy link
Author

pauly4it commented Jul 2, 2014

Thanks for the quick reply!

I removed the add-on (followed your instructions backwards), ran composer update, followed your instructions forwards, ran composer update, ran the migration, and added the routes. I still get BindingResolutionException that AuthTokenProviderInterface is not instaintiable.

How would you suggest I move forward?

By the way, I forgot to mention that I'm on Laravel v4.1, if that makes a difference.

@pauly4it
Copy link
Author

pauly4it commented Jul 2, 2014

I've figured it out. I had added the provider to app/config/app.php, but not to app/config/local/app.php. After adding it to the local app.php, it worked. It makes sense, since my environment is set for local development.

I'm pretty new to Laravel, and I didn't realize this would be an issue.

Thanks for making such a great add-on!

@pauly4it pauly4it closed this as completed Jul 2, 2014
@tappleby
Copy link
Owner

tappleby commented Jul 2, 2014

To avoid this issue it is generally best to only define override values in your local config, laravel will use the base config values if the entry is not defined in local env config.

If you need to use a service provider for local dev, laravel has a function called append_config. See the Provider Configuration docs.

@pauly4it
Copy link
Author

pauly4it commented Jul 2, 2014

I had assumed that was the default behavior, but it would seem I was wrong. Thanks for the tip!

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

2 participants