{"id":16296756,"url":"https://github.com/pgaultier/daemon","last_synced_at":"2025-06-26T02:36:49.630Z","repository":{"id":14067315,"uuid":"16770675","full_name":"pgaultier/daemon","owner":"pgaultier","description":"PHP 5.3+ basic daemon / Event loop","archived":false,"fork":false,"pushed_at":"2014-03-13T21:28:09.000Z","size":160,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"devel","last_synced_at":"2025-05-11T06:16:08.694Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pgaultier.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-02-12T14:58:25.000Z","updated_at":"2014-03-13T21:28:09.000Z","dependencies_parsed_at":"2022-09-23T18:41:55.015Z","dependency_job_id":null,"html_url":"https://github.com/pgaultier/daemon","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/pgaultier/daemon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgaultier%2Fdaemon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgaultier%2Fdaemon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgaultier%2Fdaemon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgaultier%2Fdaemon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgaultier","download_url":"https://codeload.github.com/pgaultier/daemon/tar.gz/refs/heads/devel","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgaultier%2Fdaemon/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259615781,"owners_count":22884876,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T20:23:53.888Z","updated_at":"2025-06-26T02:36:49.610Z","avatar_url":"https://github.com/pgaultier.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sweelix\\daemon for PHP\n\n## About\n\nSweelix\\daemon is a PHP 5.3+ library which is used to create long running php scripts\nThe [latest class API documentation][apidocs] is available online.\n\n## Requirements\n\nThis tiny script depends on \n\n* ext-pcntl : Process control PHP extension\n* ext-posix : PHP Posix extension\n\nIt's also recommended to install\n\n* ext-proctitle : Extension which allow the proecss name to be changed\n\n## Examples\n\nThe most useless daemon :\n\n```php\n\u003c?php\n/**\n * File Writed.php\n *\n * PHP version 5.3+\n *\n * @author    Philippe Gaultier \u003cpgaultier@sweelix.net\u003e\n * @copyright 2010-2014 Sweelix\n * @license   http://www.sweelix.net/license license\n * @version   1.0.0\n * @link      http://www.sweelix.net\n * @category  demo\n * @package   sweelix.demo\n */\n\nuse sweelix\\daemon\\Daemon;\n\n/**\n * Writed is a useless daemon which write dots in the CLI.\n * This daemon is just here to demonstrate how it can work.\n * @see sweelix/daemon\n *\n * @author    Philippe Gaultier \u003cpgaultier@sweelix.net\u003e\n * @copyright 2010-2014 Sweelix\n * @license   http://www.sweelix.net/license license\n * @version   1.0.0\n * @link      http://www.sweelix.net\n * @category  demo\n * @package   sweelix.demo\n */\nclass Writed extends Daemon {\n\n\t/**\n\t * @var integer var used to count the number of dots to display\n\t */\n\tprivate $_loopNum=0;\n\n\t/**\n\t * Init our daemon. Here we do nothing except showing we are starting\n\t * @see \\sweelix\\daemon\\Daemon::setUp()\n\t *\n\t * @return void\n\t * @since  1.0.0\n\t */\n\tpublic function setUp() {\n\t\t$this-\u003ewrite('Warming up engine'.\"\\n\");\n\t}\n\n\t/**\n\t * Clean up our daemon. Here we do nothing except showing we are stopping\n\t * @see \\sweelix\\daemon\\Daemon::tearDown()\n\t *\n\t * @return void\n\t * @since  1.0.0\n\t */\n\tpublic function tearDown() {\n\t\t$this-\u003ewrite('Cool down the engine'.\"\\n\");\n\t}\n\n\t/**\n\t * The task we are performing on each loop\n\t * We are only writing dots on the screen\n\t * @see \\sweelix\\daemon\\Daemon::task()\n\t *\n\t * @return void\n\t * @since  1.0.0\n\t */\n\tpublic function task() {\n\t\t$this-\u003e_loopNum++;\n\t\tsleep(1);\n\t\t$this-\u003ewrite('.');\n\t\tif($this-\u003e_loopNum \u003e= 10) {\n\t\t\t$this-\u003e_loopNum = 0;\n\t\t\t$this-\u003ewrite(\"\\n\");\n\t\t}\n\t}\n}\n```\n\n## Installation\n\nThe preferred method of installation is via [Packagist][] and [Composer][]. Run\nthe following command to install the package and add it as a requirement to\n`composer.json`:\n\n```bash\ncomposer.phar require sweelix/daemon=1.0.0\n```\n\n## Running\n\nNow we can run it \n\n```php\n\u003c?php\n/**\n * File test.php\n *\n * PHP version 5.3+\n *\n * @author    Philippe Gaultier \u003cpgaultier@sweelix.net\u003e\n * @copyright 2010-2014 Sweelix\n * @license   http://www.sweelix.net/license license\n * @version   1.0.0\n * @link      http://www.sweelix.net\n * @category  demo\n * @package   sweelix.demo\n */\n\n/**\n * include composer autoloader\n */\nrequire('vendor/autoload.php');\nrequire('Writed.php');\n\n$daemon = new Writed();\n// Run it\n$daemon-\u003erun();\n```\n\n[apidocs]: http://www.sweelix.net/api/namespaces/sweelix.daemon.html","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgaultier%2Fdaemon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgaultier%2Fdaemon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgaultier%2Fdaemon/lists"}