Learn about the PHP socket programming functions and how to create a daemon/service. There are two videos explaining the code that you can find here: link
Socket Programming: Video 1 Video 2
We all know HTTP is connection-less protocol, but socket programming allows you to stay connected to your users’ browser and update any information you want on the page.
Create the connection:
$socket = socket_create(AF_INET,SOCK_STREAM,0)
Binding to a specific port:
PHP
$ip = "127.0.0.1";
$port = 123;
socket_bind($socket,$ip,$port)
Listening to your customers:
socket_listen($socket)
Accept any requests:
$client = socket_accept($socket)
Server sends message to user:
// welcome the user
$message = "\n Hey! Welcome to another exciting talk! \n\n";
socket_write($client, $message, strlen($message));
Server receives message from user:
$clientMssg = socket_read($client,2048,PHP_NORMAL_READ)
Execute the following commands in your terminal.
Download Xdebug - you will need to follow alternate instructions if you don't have PHP5 working on your machine already.
sudo apt-get install php5-xdebug
The package should modify your INI file for you, but just in case you need to edit it yourself open it up and make the following modification - on Ubuntu its typically at /etc/php5/apache2/php.ini - add the following line.
zend_extension="/usr/lib/php5/20110331/xdebug.so"
That path might be a little different on your system - just make sure its a fully qualified path to the xdebug.so file on your machine. Also remember to comment out any references to the Zend Debugger - you can't run both at the same time.
Now restart Apache.
sudo /etc/init.d/apache2 restart
You may also need want enable html_errors. Search for html_errors in /etc/php5/apache2/php.ini and make sure it is set to On. A restart of Apache is also required.
html_errors = On
Double-check with phpinfo() to make sure that everything is installed properly - you may also want to set configurations for Xdebug in your php.ini file.
sudo apt-get install sqlite php5-sqlite
sudo /etc/init.d/apache2 restart
If your phpinfo() is not showing the pdo_sqlite line (in my case, on my Ubuntu Server), you just need to run the lines above and then you'll be good to go.
CURL is AWESOME to do what you want ! It's a simple but effective command line tool : http://curl.haxx.se/
curl -i -X GET <URL>
curl -i -X GET <URL>
curl -i -X DELETE <URL>
curl -i -X POST -H '<headers>' -d '<data>' <URL>
curl -i -X PUT -H '<headers>' -d '<data>' <URL>