I got maybe a little closer...
public function boot() {
$this->app['gate']->define('test', function($user, $test) { return true; });
}
FatalErrorException...
Call to undefined method Illuminate\Support\Facades\Gate::define()
The documentation section on Authorization is pretty lacking for Lumen. It says to refer the the full Laravel documentation, which I've read several times. So I want to start with step one, make a single ability and test it.
The docs say the "primary difference when using authorization in Lumen compared to Laravel is... you may simply use the Gate facade in your AuthServiceProvider to define abilities". Firstly, I have facades disabled because I've been able to do everything else without them, and I'd rather not enable them for this one feature. Anyway... you can't "simply" use the Gate facade.
Even if I enable facades, I get:
Class 'App\Providers\Gate' not found
I tried:
Use Illuminate\Contracts\Auth\Access\Gate;
Which yields
Non-static method Illuminate\Contracts\Auth\Access\Gate::define() cannot be called statically...
Right. The Laravel docs show it injected into the boot method. Lumen doesn't do that.
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
...
public function boot(GateContract $gate) {
}
Yields:
Argument 1 passed to App\Providers\AuthServiceProvider::boot() must be an instance of Illuminate\Contracts\Auth\Access\Gate, none given
If it's so simple, can someone tell me what I'm missing here?
Please or to participate in this conversation.