What is your version of ImageMagick? -connected-components needs at least version 6.8.9.10. Take out the \ and make it all one long line. Using new line \ may be confusing PHP exec().
Try it this way and increase your area-threshold to 150:
<?php
exec("convert out.pbm -define connected-components:verbose=true -define connected-components:area-threshold=150 -connected-components 4 -auto-level -depth 8 test.png 2>&1",$out,$returnval);
foreach($out as $text)
{echo "$text<br>";}
?>
It should then return:
Objects (id: bounding-box centroid area mean-color):
22: 665x500+0+0 332.0,241.1 295195 gray(0)
7605: 125x101+86+380 150.6,431.3 10246 gray(255)
6995: 139x105+476+350 541.7,401.0 10087 gray(255)
5560: 94x62+133+233 182.0,265.4 4622 gray(255)
5196: 106x61+434+217 483.3,246.8 4608 gray(255)
3470: 76x42+162+145 201.4,164.9 2448 gray(255)
3023: 76x40+401+126 438.7,145.5 2391 gray(255)
1420: 58x28+186+75 215.5,88.7 1315 gray(255)
992: 61x24+385+64 414.3,75.7 1146 gray(255)
2: 33x18+0+0 12.9,6.6 391 gray(0)
If you just want the list without the image, you can replace test.png with null:.
If you want the output to be binary rather than grayscale coded for the id numbers, then add -define connected-components:mean-color=true:
<?php
exec("convert out.pbm -define connected-components:verbose=true -define connected-components:area-threshold=150 -define connected-components:mean-color=true -connected-components 4 -auto-level -depth 8 test.png 2>&1",$out,$returnval);
foreach($out as $text)
{echo "$text<br>";}
?>
If you just want the count and the binary output, then try:
<?php
exec("convert image.jpg -define connected-components:verbose=true -define connected-components:area-threshold=150 -define connected-components:mean-color=true -connected-components 4 -auto-level -depth 8 test.png 2>&1 | grep "gray(255)" | wc -l | sed 's/^[ ]*//' ",$out,$returnval);
foreach($out as $text)
{echo "$text<br>";}
?>
Which should return 8.
See https://www.imagemagick.org/script/connected-components.php