create account

QUIQQER Composer Events by pcsg-dev

View this thread on: hive.blogpeakd.comecency.com
· @pcsg-dev ·
$18.33
QUIQQER Composer Events
QUIQQER Composer Events
======

<center>
![](https://github.com/QUIQQER/composer/raw/master/bin/images/Readme.jpg)
</center>

#### Repository

- https://github.com/QUIQQER/composer

### 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.

```
<?php

require 'vendor/autoload.php';

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

$Composer->getOutdatedPackages();
```


#### How did you implement it/them?

Commits: [843eb93](https://github.com/QUIQQER/composer/commit/843eb930aaf01aa51d34c166cadc2a605d7cccd9) [93649c0](https://github.com/QUIQQER/composer/commit/93649c0b973e17eb2440ca6eb5e4a96e1199dfa6) [f42ac7a](https://github.com/QUIQQER/composer/commit/f42ac7a2d05baaa9c6796445061ddab446676da7) [920a50e](https://github.com/QUIQQER/composer/commit/920a50ec5446beb1c03021ac0cba9eb088bcf1fe) [6bed09](https://github.com/QUIQQER/composer/commit/6bed0952baf7a3ef59db5a971ea95598cfdaffa7)

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

https://github.com/QUIQQER/composer/commit/843eb930aaf01aa51d34c166cadc2a605d7cccd9#diff-cf146ce40cbf85c9b5cf8766c4e19d76

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

![](https://cdn.steemitimages.com/DQmYBM89LuQtQy832v9LA1wP2Dq6r9kEzgmeJRwV7btbPMF/image.png)

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.

![](https://cdn.steemitimages.com/DQmcQVvNjPoZvzzhuBftK2rNCgYsLVMH7xXdsUNd8wJYjZr/image.png)

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.

![](https://cdn.steemitimages.com/DQmXLvGRR283mumuRQPvLwmHe4LP2N89RWoaqjJUDiayWN1/image.png)

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

![](https://cdn.steemitimages.com/DQmTBJenTfLxwKDkVqS32Pk34CbyNpfauFNRj3Ckw2YPe9h/image.png)

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

- https://github.com/dehenne
πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 2 others
πŸ‘Ž  
properties (23)
authorpcsg-dev
permlinkquiqqer-composer-events
categoryutopian-io
json_metadata{"tags":["utopian-io","development"],"image":["https://github.com/QUIQQER/composer/raw/master/bin/images/Readme.jpg","https://cdn.steemitimages.com/DQmYBM89LuQtQy832v9LA1wP2Dq6r9kEzgmeJRwV7btbPMF/image.png","https://cdn.steemitimages.com/DQmcQVvNjPoZvzzhuBftK2rNCgYsLVMH7xXdsUNd8wJYjZr/image.png","https://cdn.steemitimages.com/DQmXLvGRR283mumuRQPvLwmHe4LP2N89RWoaqjJUDiayWN1/image.png","https://cdn.steemitimages.com/DQmTBJenTfLxwKDkVqS32Pk34CbyNpfauFNRj3Ckw2YPe9h/image.png"],"links":["https://github.com/QUIQQER/composer","https://github.com/QUIQQER/composer/commit/843eb930aaf01aa51d34c166cadc2a605d7cccd9","https://github.com/QUIQQER/composer/commit/93649c0b973e17eb2440ca6eb5e4a96e1199dfa6","https://github.com/QUIQQER/composer/commit/f42ac7a2d05baaa9c6796445061ddab446676da7","https://github.com/QUIQQER/composer/commit/920a50ec5446beb1c03021ac0cba9eb088bcf1fe","https://github.com/QUIQQER/composer/commit/6bed0952baf7a3ef59db5a971ea95598cfdaffa7","https://github.com/QUIQQER/composer/commit/843eb930aaf01aa51d34c166cadc2a605d7cccd9#diff-cf146ce40cbf85c9b5cf8766c4e19d76","https://github.com/dehenne"],"app":"steemit/0.1","format":"markdown"}
created2019-04-12 06:05:15
last_update2019-04-12 06:05:15
depth0
children4
last_payout2019-04-19 06:05:15
cashout_time1969-12-31 23:59:59
total_payout_value14.032 HBD
curator_payout_value4.298 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length3,542
author_reputation41,490,075,306,333
root_title"QUIQQER Composer Events"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id82,931,588
net_rshares30,484,877,260,962
author_curate_reward""
vote details (67)
@justyy ·
$5.81
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](https://github.com/QUIQQER/composer/commit/843eb930aaf01aa51d34c166cadc2a605d7cccd9#diff-43a4a25b5920f2aec8a69de0c88e177cR436) 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](https://medium.com/@amlcurran/clean-code-the-curse-of-a-boolean-parameter-c237a830b7a3)

Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/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](https://review.utopian.io/result/3/2-2-3-2-2-2-2-).

---- 
Need help? Chat with us on [Discord](https://discord.gg/uTyJkNm).

[[utopian-moderator]](https://join.utopian.io/)
πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorjustyy
permlinkre-pcsg-dev-quiqqer-composer-events-20190414t164325777z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"links":["https://github.com/QUIQQER/composer/commit/843eb930aaf01aa51d34c166cadc2a605d7cccd9#diff-43a4a25b5920f2aec8a69de0c88e177cR436","https://medium.com/@amlcurran/clean-code-the-curse-of-a-boolean-parameter-c237a830b7a3","https://join.utopian.io/guidelines","https://review.utopian.io/result/3/2-2-3-2-2-2-2-","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"}
created2019-04-14 16:43:27
last_update2019-04-14 16:43:27
depth1
children1
last_payout2019-04-21 16:43:27
cashout_time1969-12-31 23:59:59
total_payout_value4.450 HBD
curator_payout_value1.362 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length991
author_reputation280,616,224,641,976
root_title"QUIQQER Composer Events"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id83,088,735
net_rshares9,416,279,217,793
author_curate_reward""
vote details (28)
@utopian-io ·
Thank you for your review, @justyy! Keep up the good work!
properties (22)
authorutopian-io
permlinkre-re-pcsg-dev-quiqqer-composer-events-20190414t164325777z-20190416t173920z
categoryutopian-io
json_metadata"{"app": "beem/0.20.17"}"
created2019-04-16 17:39:21
last_update2019-04-16 17:39:21
depth2
children0
last_payout2019-04-23 17:39:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length58
author_reputation152,955,367,999,756
root_title"QUIQQER Composer Events"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id83,213,142
net_rshares0
@steem-ua ·
#### 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](https://discord.gg/KpBNYGz)**
properties (22)
authorsteem-ua
permlinkre-quiqqer-composer-events-20190414t172541z
categoryutopian-io
json_metadata"{"app": "beem/0.20.19"}"
created2019-04-14 17:25:42
last_update2019-04-14 17:25:42
depth1
children0
last_payout2019-04-21 17:25:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length287
author_reputation23,214,230,978,060
root_title"QUIQQER Composer Events"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id83,090,446
net_rshares0
@utopian-io ·
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](https://chrome.google.com/webstore/detail/steemplus/mjbkjgcplmaneajhcbegoffkedeankaj?hl=en) or [Steeditor](https://steeditor.app)).

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

<a href='https://steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
properties (22)
authorutopian-io
permlinkre-quiqqer-composer-events-20190415t190635z
categoryutopian-io
json_metadata"{"app": "beem/0.20.17"}"
created2019-04-15 19:06:36
last_update2019-04-15 19:06:36
depth1
children0
last_payout2019-04-22 19:06:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length590
author_reputation152,955,367,999,756
root_title"QUIQQER Composer Events"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id83,156,080
net_rshares0