Bypass Laravel Backpack CrudUsageStats

Pedro Gomes
1 min readSep 9, 2019

Running Backpack in production and wondering about these usage reporting requests being sent back home?

I’m all in for OSS and supporting sustainable models but for some people, privacy and security is paramount and we operate on a need to know basis.

The information being sent, right now:

$stats = [
‘HTTP_HOST’ => $_SERVER[‘HTTP_HOST’] ?? false,
‘APP_URL’ => $_SERVER[‘APP_URL’] ?? false,
‘APP_ENV’ => $this->app->environment() ?? false,
‘APP_DEBUG’ => $_SERVER[‘APP_DEBUG’] ?? false,
‘SERVER_ADDR’ => $_SERVER[‘SERVER_ADDR’] ?? false,
‘SERVER_ADMIN’ => $_SERVER[‘SERVER_ADMIN’] ?? false,
‘SERVER_NAME’ => $_SERVER[‘SERVER_NAME’] ?? false,
‘SERVER_PORT’ => $_SERVER[‘SERVER_PORT’] ?? false,
‘SERVER_PROTOCOL’ => $_SERVER[‘SERVER_PROTOCOL’] ?? false,
‘SERVER_SOFTWARE’ => $_SERVER[‘SERVER_SOFTWARE’] ?? false,
‘DB_CONNECTION’ => $_SERVER[‘DB_CONNECTION’] ?? false,
‘LARAVEL_VERSION’ => $this->app->version() ?? false,
‘BACKPACK_BASE_VERSION’ => $_SERVER[‘BACKPACK_BASE_VERSION’] ?? false,
‘BACKPACK_CRUD_VERSION’ => $_SERVER[‘BACKPACK_CRUD_VERSION’] ?? false,
‘BACKPACK_LICENSE’ => config(‘backpack.base.license_code’) ?? false,
];

To bypass this behavior, this is what you can do:

Disable auto publishing of backpack/crud in composer.json, by adding:

“extra”: {
“laravel”: {
“dont-discover”: [
“backpack/crud”
]
}
},

Publish your new CrudServiceProvider

cp vendor/backpack/crud/src/CrudServiceProvider.php app/Providers/CrudServiceProvider.php

Disable the intended behavior, commenting the following lines:

//$this->sendUsageStats();

//use CrudUsageStats;

Search and replace the following strings

__DIR__.’

replace with

__DIR__.’/../../vendor/backpack/crud/src

Register your new service provider at config/app.php

/*
* Application Service Providers…
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
App\Providers\CrudServiceProvider::class,

And done!

Laravel Backpack is a great project with huge value add, you should definitely support it by acquiring its commercial licenses (49 eur for a single project!).

--

--