start a windows service using a webservice in php - php

I was trying to start or stop a windows service from Android Device. For this i found using webservice would be more efficient way.
So i planned to create web service using php. From php5.3 this can be achieved by using win32_query_service_status.But my server is with php4. So is there any other way to start or stop windows services using PHP

As long as you can issue system commands to the command line, you can control the services using their command-line interface. Something like:
exec('NET START ServiceName');

Related

Using SOAP on windows

I need to connect to a SOAP endpoint from a windows machine, however, the PowerShell New-WebServiceProxy cmdlet fails to process the WSDL. I can't change the WSDL, and I have the connection working in PHP.
I'm not too sure about using PHP just as a scripting tool. What other tools might be available to get the SOAP endpoint running, and C# seems overkill for this.
other features I need in the scripting tool
- watch/open a file that is created
- find rows that a different in the Files (CSV)

Using AWS for SQL and REST frontend

I'm trying to set up a PostgreSQL db with a REST(php) gate. I want to access this database the standard REST way (using GET and Headers), from a C# application.
Currently I am using a standard web hoster that has a MySQL database, but I want to jump ship to PostgreSQL.
Am I right in thinking Amazon's EC2 servers a good choice to do this? I just need a server with PostgreSQL installed and a bunch of php scripts (for REST).
Thanks
EC2 would work fine, or you could use an RDS PostgreSQL instance, and just run the PHP scripts on a small EC2 instance.
Check out restSQL. It's an open-source, ultra-lightweight persistence layer, with out of the box PostgreSQL support.
It's written in Java but you can use its HTTP API by deploying the service in a standard JEE container, e.g. Tomcat, or as a Docker container. The latest versions are on bundled as images on docker hub.
You can take it for a spin using the sandboxed instance and explore the docs at http://restsql.org.

Interact NodeJS and PHP without "intermediate" (like redis)

i need ideas to solve this:
I have a entire website in PHP (5.2) in a PHP "shared server", only i can use apache+PHP, CGI & NodeJS, no memcached, redis or another software.
And i need to comunicate the PHP and the NodeJS Script.
My first approach is using socket connection, creating in NodeJS a socket listener and connect to it witch PHP, and then, send commands, whait for response, and close connection (and end PHP Script). To the other side, i can call PHP script via ¿httprequest? ¿or using sockets again?
The problem of using sockets fron Node to PHP, i CANT leave PHP script runing with set_time_limit(0) because the fuc... server, need to "call" PHP for another way.
The NodeJS and Apache + PHP are in the same machine, i need to make the code for the fast response time (sockets better than web-calls).
Better ideas or other solutions?
thanks!
Try memcached it's easy and very fast.

What do I need for the server side for a websocket?

I am using the following js plugin which allows me to use WebSockets on android and iOS with apps written in html5 (via phonegap in my case).
https://github.com/FreakDev/PhoneGap-Android-HTML5-WebSocket
What else do I need in order to use a websocket?
I have a basic server with bluehost that has PHP and MySQL installed.. What am I going to need to do?
First you can use a library like this one:
http://code.google.com/p/phpwebsocket/
Second, your host must let you create sockets. This mean PHP must have php_sockets.dll (Win) or sockets.so (Linux) extension enabled and a forwarded port from your server.
Also you need to run your php from commend line or somehow keep it alive for ever.
It is just like creating a normal socket in PHP.
*Edit:
WebSockets are just some sort of normal sockets. In websocket you can connect to a endpoint which is listening for connections and then communicate with it. Just like normal sockets but with simple differences in protocol and more limitations. For doing so you need a script or application to run for ever and handle all connections from webpages. But a php file will end just after request ended. For keeping a php file running for ever you need to run it from commend line which mean you need to have shell access, or you can use this code to run your php script for ever: (But you must think about a mechanism to call it only once)
ignore_user_abort(true);
ini_set('max_execution_time', 0);
set_time_limit(0);
You can test. If your application fail with error messages about not knowing a function like socket_connect or socket_bind then you don't have socket extension for php.
Here is phpwebsocket files for download:
http://phpwebsocket.googlecode.com/svn/trunk/%20phpwebsocket/
There is an example there too.
As "Tom van der Woerdt" said PHP is not designed for doing socket programming. Go for a non-scripting language and use a dedicated server or at least a vps for opening and managing sockets.

Amazon EC2 Micro Instance

I am looking for a way to automatically turn off/on a microinstance on session based intervals. I need to be able to do this to automate when I am paying for the EC2 server. Does anyone know of any ways to do this using PHP or some other backend technology
You can always start and stop instances using the AWS command line tools (i.e. make a BASH script to do this) or by using the AWS PHP SDK. Of course the problem is that you will need some separate server on which you can run a cron or similar to execute your start/stop scripts.
Zend Framework 1.x have some classes to work with Amazon EC2 (Zend_Service_Amazon_Ec2).

Categories