47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Aws\S3\S3Client;
|
|
use Domnikl\Statsd\Connection\Blackhole;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
|
|
public function boot(){
|
|
Schema::defaultStringLength(191);
|
|
}
|
|
|
|
/**
|
|
* Register any application services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function register()
|
|
{
|
|
$this->app->singleton(S3Client::class, function() {
|
|
$s3 = new S3Client([
|
|
'region' => 'eu-west-1',
|
|
'version' => 'latest',
|
|
'credentials' => [
|
|
'key' => getenv("S3_ACCESS_KEY"),
|
|
'secret' => getenv("S3_SECRET")
|
|
]
|
|
]);
|
|
return $s3;
|
|
});
|
|
|
|
$this->app->singleton(\Domnikl\Statsd\Client::class, function() {
|
|
$server = getenv("STATSD");
|
|
if($server && $server != "") {
|
|
$connection = new \Domnikl\Statsd\Connection\UdpSocket($server, 8125);
|
|
} else {
|
|
$connection = new Blackhole();
|
|
}
|
|
$statsd = new \Domnikl\Statsd\Client($connection, "account.".getenv("STATSD_PREFIX"));
|
|
return $statsd;
|
|
});
|
|
}
|
|
}
|