Session_name(): Cannot change session name when headers already sent

Guten Tag,

Ich möchte auf der Detail-Seite ein var_dump (‚hello‘); ausgeben, ich habe deswegen dieses Event bgenutzt:

<?php declare(strict_types=1);

namespace Swag\StarterPack\Storefront\Subscriber;

use Shopware\Storefront\Page\Product\ProductPageLoadedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class ProductSubscriber implements EventSubscriberInterface
{
    
    public static function getSubscribedEvents(): array
    {
        return [
            ProductPageLoadedEvent::class => 'onProductPageLoaded'
        ];
    }
    
    /**
     * @param ProductPageLoadedEvent $event
     * @throws \Exception
     */
    public function onProductPageLoaded(ProductPageLoadedEvent $event): void
    {
        var_dump("hello");
    }
}

Wenn ich jetzt auf auf die Detailseite gehe, kriege ich von der debuger Folgende Error.
Uncaught PHP Exception ErrorException: "Warning: session_name(): Cannot change session name when headers already sent" at /www/htdocs/w0119997/orderandfriends.com/vendor/symfony/http-foundation/Session/Storage/Proxy/AbstractProxy.php line 116

Was ist das Problem ? Danke sehr.

Warum reagiert shopware so wenn ich vardumps netzen möchte ?

Du sendest an den Browser einen String bevor der Header gesendet wurde. Das hat nichts mit Shopware zu tun sondern mit dem http-Protokoll.