Skip to content

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.

Notifications You must be signed in to change notification settings

adhir2099/PHP-DAEMON

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages