Skip to content

Cannot Access some $App components inside ServiceProvider #25

Closed
@raftalks

Description

@raftalks

I have created a basic workbench package and I am trying to inject Auth class instance to the main class of the package. It seems some of the components like Auth, Log, are not available inside the register method when using $this->app['auth'] or $this->app['log'].

It seems they are not loaded when the register method is called on service provider of workbench package.

I am getting the following errors
ReflectionException: Class auth does not exist
ReflectionException: Class log does not exist

This is the Service Provider Class I am using

<?php namespace Hbt\Acl;

use Illuminate\Support\ServiceProvider;

class AclServiceProvider extends ServiceProvider {

    /**
     * Indicates if loading of the provider is deferred.
     *
     * @var bool
     */
    protected $defer = false;

    /**
     * Bootstrap the application events.
     *
     * @return void
     */
    public function boot()
    {
        $this->package('hbt/acl');
    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
                $log = $this->app['log'];
                $auth = $this->app['auth'];
        $this->app['acl'] = new Acl($auth , $log);
    }

....

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions