<?php
/**
 * @package Puzzle-DI
 * @copyright Copyright © 2015 Danny Smart
 */

namespace Lexide\PuzzleDI\Plugin;

use Composer\Composer;
use Composer\EventDispatcher\EventSubscriberInterface;
use Composer\IO\IOInterface;
use Composer\Plugin\PluginInterface;
use Composer\Script\Event;
use Composer\Script\ScriptEvents;
use Lexide\PuzzleDI\Controller\ScriptController;

class PuzzlePlugin implements PluginInterface, EventSubscriberInterface
{
    /**
     * {@inheritDoc}
     */
    public static function getSubscribedEvents()
    {
        return [
            ScriptEvents::POST_INSTALL_CMD => ['runPlugin'],
            ScriptEvents::POST_UPDATE_CMD => ['runPlugin']
        ];
    }

    /**
     * {@inheritDoc}
     */
    public function activate(Composer $composer, IOInterface $io)
    {
        // move along, nothing to see here
    }

    /**
     * @param Event $event
     */
    public function runPlugin(Event $event)
    {
        $controller = new ScriptController();
        $controller->compileConfigList($event);
    }

} 

<?php
/**
 * @package Puzzle-DI
 * @copyright Copyright © 2015 Danny Smart
 */

namespace Lexide\PuzzleDI\Plugin;

use Composer\Composer;
use Composer\EventDispatcher\EventSubscriberInterface;
use Composer\IO\IOInterface;
use Composer\Plugin\PluginInterface;
use Composer\Script\Event;
use Composer\Script\ScriptEvents;
use Lexide\PuzzleDI\Controller\ScriptController;

class PuzzlePlugin implements PluginInterface, EventSubscriberInterface
{
    /**
     * {@inheritDoc}
     */
    public static function getSubscribedEvents()
    {
        return [
            ScriptEvents::POST_INSTALL_CMD => ['runPlugin'],
            ScriptEvents::POST_UPDATE_CMD => ['runPlugin']
        ];
    }

    /**
     * {@inheritDoc}
     */
    public function activate(Composer $composer, IOInterface $io)
    {
        // move along, nothing to see here
    }

    /**
     * @param Event $event
     */
    public function runPlugin(Event $event)
    {
        // If puzzle has been removed in this update, the script controller may no longer exist
        if (!class_exists("\\Lexide\\PuzzleDI\\Controller\\ScriptController")) {
            return;
        }

        $controller = new ScriptController();
        $controller->compileConfigList($event);
    }

} 

Fix "class not found" bug when removing puzzle from composer
Fix "class not found" bug when removing puzzle from composer
