Skip to content

Latest commit

 

History

History
48 lines (36 loc) · 1.33 KB

README.md

File metadata and controls

48 lines (36 loc) · 1.33 KB

PHP

PHP DAEMON

Need to run a PHP “service” or script in the background? Send out emails, free memory, or monitor something? An easy alternative way to do all of those things is a PHP daemon directly executed on CMD/CLI.

Config parameters

Run in the command line –> php fileName.PHP

If you have issue running the php command, add php to your path on system environment variables.

If you want the script to run infinitely:

    while (true) { /* DO SOMETHING */ sleep(1); }

Wait 5s between cycles, here you can edit the time the script has to be executed if the script is enabled to run infinitely.

    define("CYCLE_PAUSE", 5);

Here is the basic use:

// include CMD/CLI script, if not included this wont work by CMD/CLI
require "cli.php";
// pause between cycles
define("CYCLE_PAUSE", 5);
// do something code
while (true) {
  echo "PHP rules!" . PHP_EOL;
  sleep(CYCLE_PAUSE);
}

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b your-branch
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin your-branch
  5. Submit a PR

Creator

Maintenance

Maintenance