antonioribeiro / tracker

Laravel Stats Tracker
MIT License
2.9k stars 595 forks source link

Facade isn't working #201

Open RosiersRobin opened 8 years ago

RosiersRobin commented 8 years ago

Hi

I tried to use the facade with this code:

Tracker::currentSession()

But it returns this:

Class 'App\Http\Controllers\Tracker' not found

I included it in my app.php config file like this;

'Tracker' => PragmaRX\Tracker\Vendor\Laravel\Facade::class,

Any ideas?

kevincobain2000 commented 8 years ago
use Tracker;
RosiersRobin commented 8 years ago

Call to undefined method PragmaRX\Tracker\Vendor\Laravel\Facade::currentSession()

Also with the use Tracker; included.

kevincobain2000 commented 8 years ago

Perhaps missing the provider in config/app.php ?

'providers' => [
       PragmaRX\Tracker\Vendor\Laravel\ServiceProvide::class,
]

'aliases' => [
     'Tracker' => PragmaRX\Tracker\Vendor\Laravel\Facade::class,
]
RosiersRobin commented 8 years ago

PragmaRX\Tracker\Vendor\Laravel\ServiceProvider::class, is in my providers. So I really don't know why it isn't working. I just followed the steps from the readme.md.

ndberg commented 7 years ago

Having the same problem since the update to Laravel 5.4

sammagafu commented 7 years ago

how do you add geoip facades and alias. thank you?

LocNguyen87 commented 6 years ago

I'm having the same issue. Any solution please ?

hamzafaouzi commented 6 years ago

guys just enable logging and everything will work

kevingio commented 6 years ago

still no solution?

@hamzafaouzi which log should be enable?

napestershine commented 5 years ago

@kevingio 'log_enabled' => false,

try changing this to 'log_enabled' => true,

drbyte commented 5 years ago

@napestershine I believe this bug can be fixed with this change: src/Vendor/Laravel/ServiceProvider.php

    protected function registerTracker()
    {
-        $this->app->singleton('tracker', function ($app) {
+        $this->app->singleton(Tracker::class, function ($app) {
            $app['tracker.loaded'] = true;

            return new Tracker(
                                    $app['tracker.config'],
                                    $app['tracker.repositories'],
                                    $app['request'],
                                    $app['router'],
                                    $app['log'],
                                    $app,
                                    $app['tracker.messages']
                                );
        });
+        $this->app->alias(Tracker::class, 'tracker');
    }