# Theme kompilieren lassen, wenn Pluginkonfiguration gespeichert wird

**URL:** https://forum.shopware.com/t/theme-kompilieren-lassen-wenn-pluginkonfiguration-gespeichert-wird/43167
**Category:** Programmierung
**Created:** [27. Januar 2017 um 08:33 UTC](https://forum.shopware.com/t/theme-kompilieren-lassen-wenn-pluginkonfiguration-gespeichert-wird/43167 "2017-01-27T08:33:30Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![HamdIT](https://avatars.discourse-cdn.com/v4/letter/h/e56c9b/32.png) [@HamdIT](https://forum.shopware.com/u/HamdIT)
#### Post date: [27. Januar 2017 um 08:33 UTC](https://forum.shopware.com/t/theme-kompilieren-lassen-wenn-pluginkonfiguration-gespeichert-wird/43167/1 "2017-01-27T08:33:30Z")

</div>

Ich will dem Nutzer anbieten sein Theme zu kompilieren, sobald er die Konfiguration meines Plugins speichert. Oder nicht einmal anbieten, einfach kompilieren. Ist das möglich?

Das Event zum Speichern ist mir bekannt:&nbsp;Shopware\_Controllers\_Backend\_Config\_After\_Save\_Config\_Element

Nur wie kann ich das aktive theme kompilieren lassen?

---

<div class="post-metadata">

### Author: ![t2oh4e](https://avatars.discourse-cdn.com/v4/letter/t/a5b964/32.png) [@t2oh4e](https://forum.shopware.com/u/t2oh4e)
#### Post date: [27. Januar 2017 um 13:45 UTC](https://forum.shopware.com/t/theme-kompilieren-lassen-wenn-pluginkonfiguration-gespeichert-wird/43167/2 "2017-01-27T13:45:52Z")

</div>

Schau dir mal hier die execute-function an. Da müsstest du alles finden was du brauchst:&nbsp;[shopware/ThemeCacheGenerateCommand.php at 5.2 · shopware/shopware · GitHub](https://github.com/shopware/shopware/blob/5.2/engine/Shopware/Commands/ThemeCacheGenerateCommand.php)

---

<div class="post-metadata">

### Author: ![HamdIT](https://avatars.discourse-cdn.com/v4/letter/h/e56c9b/32.png) [@HamdIT](https://forum.shopware.com/u/HamdIT)
#### Post date: [27. Januar 2017 um 14:14 UTC](https://forum.shopware.com/t/theme-kompilieren-lassen-wenn-pluginkonfiguration-gespeichert-wird/43167/3 "2017-01-27T14:14:34Z")

</div>

Danke für die Antwort. Das hier ist mein Versuch (Ich kriege den Pfeil im Forum nicht angezeigt):

```
   public static function getSubscribedEvents()
    {
        return ['Shopware_Controllers_Backend_Config_After_Save_Config_Element' => 'onSave'];
    }

    public function onSave(\Enlight_Event_EventArgs $args)
    {
        $repository = $this->container->get('models')->getRepository('Shopware\Models\Shop\Shop');
        $query = $repository->getShopsWithThemes();
        $shops = $query->getResult(
            AbstractQuery::HYDRATE_OBJECT
        );
        if (empty($shops)) {
            //$output->writeln('No theme shops found');
            return;
        }
        /** @var $compiler \Shopware\Components\Theme\Compiler */
        $compiler = $this->container->get('theme_compiler');
        foreach ($shops as $shop) {
           // $output->writeln(sprintf('Generating theme cache for shop "%s" ...', $shop->getName()));
            $compiler->compile($shop);
        }
       // $output->writeln('Clearing HTTP cache ...');
        /** @var $cacheManager CacheManager */
        $cacheManager = $this->container->get('shopware.cache_manager');
        $cacheManager->clearHttpCache();
    }

```

&nbsp;

Leider klappt das nicht. Der $compiler und der $shop werden noch korrekt geholt. Beim Aufruf von compile($shop) geht’s nicht weiter.&nbsp;Erstmal passiert gar nichts und dann kommt communication failure.&nbsp;

&nbsp;

---

<div class="post-metadata">

### Author: ![t2oh4e](https://avatars.discourse-cdn.com/v4/letter/t/a5b964/32.png) [@t2oh4e](https://forum.shopware.com/u/t2oh4e)
#### Post date: [27. Januar 2017 um 20:16 UTC](https://forum.shopware.com/t/theme-kompilieren-lassen-wenn-pluginkonfiguration-gespeichert-wird/43167/4 "2017-01-27T20:16:29Z")

</div>

Theme kompilieren dauert ja eine Weile… kann es sein, dass du einfach in einen Timeout läufst?

---

<div class="post-metadata">

### Author: ![snapdragon](https://avatars.discourse-cdn.com/v4/letter/s/8baadc/32.png) [@snapdragon](https://forum.shopware.com/u/snapdragon)
#### Post date: [31. Januar 2017 um 08:34 UTC](https://forum.shopware.com/t/theme-kompilieren-lassen-wenn-pluginkonfiguration-gespeichert-wird/43167/5 "2017-01-31T08:34:07Z")

</div>

Hi,

communication failure kommt dann, wenn der Shop nicht genügend Resourcen hat und läuft dann ein einen Timeout. Probier doch mal, in der htaccess (Root des Shops) den zugewiesenen Speicher höher zu setzen und die Execution-Time auf 120 Sek. (auch in der htaccess). Das Ganze hängt stark vom Provider ab. Bei einigen hat man diese Probleme nicht.

Grüße

Frank

---

<div class="post-metadata">

### Author: ![HamdIT](https://avatars.discourse-cdn.com/v4/letter/h/e56c9b/32.png) [@HamdIT](https://forum.shopware.com/u/HamdIT)
#### Post date: [31. Januar 2017 um 18:49 UTC](https://forum.shopware.com/t/theme-kompilieren-lassen-wenn-pluginkonfiguration-gespeichert-wird/43167/6 "2017-01-31T18:49:07Z")

</div>

Okay, werde ich versuchen. Aber ich habe auch schon viele Plugins installiert, die nach dem Speichern das Theme kompilieren (mit schickem Kompilier-Fenster). Und da klappt es ja auch wunderbar. Auch kann ich das Theme von Hand kompilieren (im backend und in der Console)&nbsp;. Execution-Time scheint mir daher nicht das Problem zu sein.

---

<div class="post-metadata">

### Author: ![corre](https://avatars.discourse-cdn.com/v4/letter/c/ba9def/32.png) [@corre](https://forum.shopware.com/u/corre)
#### Post date: [14. Februar 2017 um 09:01 UTC](https://forum.shopware.com/t/theme-kompilieren-lassen-wenn-pluginkonfiguration-gespeichert-wird/43167/7 "2017-02-14T09:01:21Z")

</div>

Hi!

Da Problem hatte ich auch, egal ob update oder Performance Modul. Hab dann die PHP.ini bearbeitet, erst die executuion Time erhöht ohne Erfolg. Dann den mysql Timeout auf 360 erhöht und seit dem ist alles wieder gut.

Grüße

Michael

&nbsp;

---

<div class="post-metadata">

### Author: ![derwunner](https://avatars.discourse-cdn.com/v4/letter/d/e5b9ba/32.png) [@derwunner](https://forum.shopware.com/u/derwunner)
#### Post date: [15. Februar 2017 um 19:19 UTC](https://forum.shopware.com/t/theme-kompilieren-lassen-wenn-pluginkonfiguration-gespeichert-wird/43167/8 "2017-02-15T19:19:38Z")

</div>

Ja, weil es nichts bringt, in der php.ini die max\_execution\_time zu erhöhen, wenn das in Shopware via ini\_set wieder anders gesetzt wird. Soetwas muss direkt in die config.php unter dem Schlüssel php\_settings (siehe Doku).

---

<div class="post-metadata">

### Author: ![daMardl](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@daMardl](https://forum.shopware.com/u/daMardl)
#### Post date: [5. März 2018 um 21:54 UTC](https://forum.shopware.com/t/theme-kompilieren-lassen-wenn-pluginkonfiguration-gespeichert-wird/43167/9 "2018-03-05T21:54:15Z")

</div>

Ich hab da auch mal was geschrieben.

[https://forum.shopware.com/discussion/comment/191672/#Comment\_191672](https://forum.shopware.com/discussion/comment/191672/#Comment_191672)

Vielleicht hilft es irgend jemanden

Gruß  
​DaMardl

---

<div class="post-metadata">

### Author: ![Seeh](https://avatars.discourse-cdn.com/v4/letter/s/ba8739/32.png) [@Seeh](https://forum.shopware.com/u/Seeh)
#### Post date: [12. August 2018 um 19:17 UTC](https://forum.shopware.com/t/theme-kompilieren-lassen-wenn-pluginkonfiguration-gespeichert-wird/43167/10 "2018-08-12T19:17:44Z")

</div>

> [@t2oh4e schrieb:](https://forum.shopware.com/profile/6202/t2oh4e "t2oh4e")
> 
> Theme kompilieren dauert ja eine Weile… kann es sein, dass du einfach in einen Timeout läufst?

Sicher dumme Frage … Wie kompiliert man eigentlich sein Theme?&nbsp;

---

<div class="post-metadata">

### Author: ![daMardl](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@daMardl](https://forum.shopware.com/u/daMardl)
#### Post date: [12. August 2018 um 21:41 UTC](https://forum.shopware.com/t/theme-kompilieren-lassen-wenn-pluginkonfiguration-gespeichert-wird/43167/11 "2018-08-12T21:41:28Z")

</div>

![](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/b/bfe1a611eac7f86e880d1c1a47ec716a52608846.png)

&nbsp;

Einstellung -\> Cache / Performace

&nbsp;

gruß

DaMardl
