QUIQQER Composer Events

in #utopian-io3 years ago

QUIQQER Composer Events


New Features

What feature(s) did you add?

Composer is in the PHP world what NPM is in the nodejs world. QUIQQER has therefore been building on Composer since its beginnings and has it deeply integrated. So that the integration works over the web and over the console we have built a bridge which can communicate between CLI and web.

The problem was, a direct output was made on the console and therefore it could not be intercepted. In some cases you might want to log the output or continue working with it. To solve this problem we implemented Symfony Process Handling and integrated an Event Handling.

Now it is possible to react to the output event and continue working with the output.


require 'vendor/autoload.php';

$Composer = new QUI\Composer\Composer(dirname(__FILE__));
$Composer->addEvent('onOutput', function ($self, $output, $type) {
    echo $output;


How did you implement it/them?

Commits: 843eb93 93649c0 f42ac7a 920a50e 6bed09

So that the Composer class can fire events at all, a completely new event class was introduced.


Afterwards this event class was integrated in all three composer classes, main Composer class, CLI class and the Web class.

An addEvent method was introduced so that the event can also be registered on the Composer instance. The same procedure was used in the main Composer class and in the Web composer class.

Now that all three installation classes have the event handling integrated, it is possible to react to the onOutput event (in the theory). For the whole thing to work the output event has to be executed as well.

The CLI it is a little bit tricky and not so simple, because the output is a direct output. This meant that some changes had to be made here. Symfony offers a good process class which executes a CLI command and the output can be intercepted on the fly. I.e. all system commands had to be started with such a process.

In order for the whole thing to work, we have centrally introduced a method which implements such a procedure.

After all commands were adjusted, the integration of the event handling was perfect.

Logging is now no longer a problem and also further handling with the output can be managed. With this feature QUIQQER has taken another step towards version 1.3.

Thanks for reading,
Hen, for PCSG Developers

GitHub Account


Thank you for your contribution.

I can see that you have replaced many instances of array() with [] but AFAIK, array() has a better backward compatibility.

Here a typo? (!isset($matches[1]) || !isset($matches[1]) || !isset($matches[1]))

Also, the usage of boolean parameters may be hint of code smell. See this

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.

Need help? Chat with us on Discord.


Thank you for your review, @justyy! Keep up the good work!

Hi @pcsg-dev!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hey, @pcsg-dev!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.22
TRX 0.07
JST 0.032
BTC 21463.83
ETH 1233.00
USDT 1.00
SBD 3.22