I use takielias Codeigniter websocket in my project for notification purpose, first of all i am noob for websocket handshaking connection and WS protocol, here every thing working as per the takielias github page documentation, in his git hub page after all setup, need to run cmd command for run server client connection command is php index.php welcome index
after run this command in the project path websocket connection is switched and every thing is working fine in my local, after uploading on server there i can’t run this command manually,
so i need a help with this, run that command and execute the socket connection, then i decide to run that command via php script, but i can’t able to execute that command successfully in local, if any other possible way to make a socket connection with client please assist me,
I really Appreciate your help,
Advertisement
Answer
As I understood, you need to execute the command via php script. You can do so using shell_exec
or exec
.
See documentation here:
exec
shell_exec
Example:
shell_exec("/path/to/php /var/www/html/index.php welcome index '".$parmeter1."' '".$parmeter2."' >> /path/to/logs/welcome.log &");
If you want to run the command in background then it is important to put & at the end.
The extra variables surrounded in single quotes after the path to the script are optional. You can omit them if not needed.