Skip to content

Commit 0b415a4

Browse files
committed
Added new example
1 parent 3ab5090 commit 0b415a4

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ script.php
1919
```php
2020
<?php
2121

22-
require_once '../vendor/autoload.php';
22+
require_once './vendor/autoload.php';
2323

2424
use Utopia\CLI\CLI;
2525
use Utopia\CLI\Console;
@@ -96,6 +96,22 @@ echo $stdout; // ''
9696
echo $stderr; // 'error'
9797
```
9898

99+
### Create a Daemon
100+
101+
You can use the `Console::loop` command to create your PHP daemon. The `loop` method already handles CPU consumption using a configurable sleep function and calls the PHP garbage collector every 5 minutes.
102+
103+
```php
104+
<?php
105+
106+
use Utopia\CLI\Console;
107+
108+
include __DIR__.'/../../vendor/autoload.php';
109+
110+
Console::loop(function() {
111+
echo "Hello World\n";
112+
}, 200000 /* 200ms */);
113+
```
114+
99115
## System Requirements
100116

101117
Utopia Framework requires PHP 7.3 or later. We recommend using the latest PHP version whenever possible.

0 commit comments

Comments
 (0)