fideloper / Implementing-Laravel

Companion application to the e-book Implementing Laravel
173 stars 40 forks source link

Target [Project\Backend\Service\Validation\ValidableInterface] is not instantiable. #28

Closed olimorris closed 9 years ago

olimorris commented 9 years ago

Having real problems with this having just bought your book Chris. Absolutely driving me mad and I can see no reason why this isn't working. I have pasted my code http://laravel.io/bin/De0Xj#11 and also at http://stackoverflow.com/questions/27760392/how-do-i-solve-target-interface-is-not-instantiable-in-laravel-4.

I know you closed this off in #14 but I just cannot find a solution to this at all.

fideloper commented 9 years ago

If I remember right, I injected specific validations - there are too many implementations of the validation service (or rather, there's more than one used at any time, since one is made per ... form or action anything that needs validation) to inject based on the interface.

Inject the specific validator you want to use there.

I haven't updated the book on this, but consider suing Command Bus as well - it's the next logical step after that. Basically a more refined way to do the same thing. Laravel 5 will have this baked in, so it'll be good to learn about!

This looks like a reasonable implementation of it: http://culttt.com/2014/11/10/creating-using-command-bus/ -- and I use it in a repository for a talk I made here: https://github.com/fideloper/hexagonal-php/tree/master/src/Hex