mivita/app/Providers/AppServiceProvider.php
Kevin e1c6178bc7 Git-Deploy per Tag: deploy.sh, Version aus RELEASE, Worker-Pruefung
- dev/betrieb/deploy.sh: Tag auschecken, composer, Caches leeren (bewusst
  kein route:/config:cache wegen hostabhaengiger Routen und env()-Aufrufen),
  horizon:terminate, FPM-Reload, Worker-Pruefung am Ende
- dev/betrieb/README.md: Einrichtung Server, Umstellung des Live-Verzeichnisses,
  Release, Deploy, Rollback
- config('app.version') aus RELEASE, php artisan about --only=mivita
- monitoring:queue-probe prueft nach dem Deploy, ob Horizon Jobs abholt
- Vorlage dev/git-deploy-monitoring aus Pressekonto

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 10:11:34 +00:00

87 lines
3.2 KiB
PHP

<?php
namespace App\Providers;
use App\Services\Backoffice\BackofficeDashboardService;
use App\Services\Payment\Payone\PayonePaymentService;
use App\Services\Payment\Stripe\StripeClientWrapper;
use App\Services\Util;
use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider;
use Illuminate\Foundation\Console\AboutCommand;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Schema::defaultStringLength(191);
Paginator::defaultView('pagination::bootstrap-4');
Paginator::defaultSimpleView('pagination::simple-bootstrap-4');
if ($this->app->environment('production')) {
URL::forceScheme('https');
}
AboutCommand::add('mivita', fn (): array => [
'Version' => config('app.version') ?? 'unbekannt',
]);
// Domain-bewusster View Composer für user_shop
// HOTFIX: DomainContext temporär deaktiviert
// TODO: Nach Claude v2 Implementation wieder aktivieren
\View::composer('*', function ($view) {
try {
// $context = app(\App\Domain\DomainContext::class);
// if ($context->type === 'main') {
// $view->with('user_shop', null);
// } else {
// $userShop = $context->userShop ?? \App\Services\Util::getUserShop();
// $view->with('user_shop', $userShop);
// }
// Temporär: Verwende immer das normale Verhalten
$view->with('user_shop', Util::getUserShop());
} catch (\Exception $e) {
// Fallback bei Fehlern
$view->with('user_shop', Util::getUserShop());
}
});
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
// PAYONE payment service: built from merchant defaults, real Guzzle client at runtime.
// The per-request `mode` is always passed explicitly to the service methods, so the
// shared singleton needs only the base defaults from config.
$this->app->singleton(PayonePaymentService::class, function () {
return new PayonePaymentService(config('payone.defaults'));
});
// Stripe: lazy Client-Hülle; Hard-Fail erst bei Nutzung ohne STRIPE_SECRET
// (Dark-Launch-fähig, siehe config/stripe.php + dev/2026-07-08-stripe/).
$this->app->singleton(StripeClientWrapper::class, function () {
return new StripeClientWrapper(config('stripe.secret'));
});
// Dashboard-Services teilen die Baum-Traversierung (lineBuckets-Memo):
// als Singleton läuft die Downline-BFS pro Request/Prozess nur einmal je Root.
$this->app->singleton(BackofficeDashboardService::class);
if ($this->app->environment() !== 'production' && class_exists(IdeHelperServiceProvider::class)) {
$this->app->register(IdeHelperServiceProvider::class);
}
}
}