I have integrated some script on my php file. It is reading the Pusher channel and does several actions when there is a new event on the listed channel.
If I run on the browser:
http:/localhost/pusher.php
and let it open the pusher connection keeps reading, however if I close it OR run on the command line:
php pusher.php
the script opens and ends in less than one second closing the connection and not reading future entries.
Question: What is the simpler way to run the (pusher) js and keep it opened and reading under the command line?
<?php require 'vendor/autoload.php'; ?>
<html>
<script src="//js.pusher.com/2.2/pusher.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript" language="javascript"> var pusher = new Pusher('key'); var channel = pusher.subscribe('betfair');
    channel.bind('bets', function(data) {
      var a = data.market_id;
      var b = data.selection;
      var c = data.stake;
      var d = data.odd;
      var e = data.bet_type;
        record(a, b, c, d, e); 
    });
function record(a,b,c,d,e) {    console.log(a);
    jQuery.ajax({
        type: "POST",
        url: 'time2.php',
        data: {a, b , c , d, e}, 
        success:function(record) {
         console.log(data); 
         }
    });
     }    
</script> </html>
 
     
    