This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
php execute a background process
I need to get some info from the user, send them some text back and process the data in the background, so after sending the text connectionwith browser should be closed and then the data processed.
How to achieve that?
You'll most likely want to save the information to a database and write some sort of daemon that processes the information offline. The PEAR System_Daemon would be a great starting point.
Some sections of their documentation you might be interested in:
What is Daemon
Daemons vs Cronjobs
Installation
Example
You may get use of pcntl_fork. See the manual example.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I need to create an application in php with a background thread containing an timer that keeps updating a database (by collecting data from different sites) separately without any user interference. What I mean by this is: without anybody visiting the site, the thread has to keep updating a database. Is this possible in PHP and how am I able to realise this ?
The best way I think it is to create a php script to do whatever you want and then set up a cron job to run that script at specific time.
There are several options for this:
A scheduled task in your operating system, such as cron on *nix or Windows Scheduler for the Windows platform.
A permanently running script. This is not ideal for PHP though, as memory usage is sometimes not correctly thrown away, and the script can run out of memory. It is common for scripts to be set to die and respawn, to prevent this from happening.
A scheduled task in your database server. MySQL now supports this. If your purpose is to run database updates, this might be a good option, if you are running MySQL, and if your version is sufficiently recent.
A queue, where some processing is done in the background upon a request signal. See Gearman, Resque and many others. It is useful where a user requests something in a web application, but that request is too lengthy to carry out immediately. If you need something to run permanently then this may not be ideal - I add it for completeness.
Having a PHP process run for a long time isn't really a good idea because PHP isn't a very memory efficient language and PHP processes consume a lot of memory.
It would be better to use a job manager. Take a look at Gearman.
This question already has answers here:
Best solution to protect PHP code without encryption
(11 answers)
Can you "compile" PHP code and upload a binary-ish file, which will just be run by the byte code interpreter?
(14 answers)
Closed 9 years ago.
Not sure if this has been discussed before.
I was looking for a solution that can protect the PHP code.
So even if I put the code on my client's server if they decide to put another developer on it or try to resell my code they should not be able to do so.
Is that even remotely possible?
The .exe versions of desktop application thingy is something I am looking for, but for PHP.
There are options to "compile" code like phpcompiler also read another thread about this on stackoverflow
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
php-cgi running very slowly on windows
I'm running wordpress on a windows server, and for some reason the php code is executing very slowly. How would I be able to trace exactly the part of the code that is slowing the server down?
Try to start with xdebug php extension. It could give you a lot of information.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Asynchronous shell exec in PHP
i'm witing a php script which convert video into FLV.when the converting is in progress the user has to wait for completion of converting but What I want to do is when the converting is in process the script continue the next lines after shell_exec .How should I do that?
Thanks
As Jared said, try looking at Asynchronous shell exec in PHP
This question already has answers here:
Closed 11 years ago.
Possible Duplicates:
PHP web server in PHP?
http server in php
I want to use HTTP server written on PHP instead of Apache. Who knows solutions? Best is one php file.
It was done once for some kind of a proof of concept we did, as PHP is faster to develop in than, say CPP. but in no way it is a solution for a production environment.
Others have done so too http://nanoweb.si.kz/ is one for example.