Skip to content

Commit aa2589f

Browse files
committed
chore: remove console
1 parent e41c8d0 commit aa2589f

File tree

6 files changed

+2189
-602
lines changed

6 files changed

+2189
-602
lines changed

README.md

Lines changed: 2 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ script.php
2020
<?php
2121
require_once './vendor/autoload.php';
2222

23+
use Utopia\Console;
2324
use Utopia\CLI\CLI;
24-
use Utopia\CLI\Console;
2525
use Utopia\CLI\Adapters\Generic;
2626
use Utopia\Http\Validator\Wildcard;
2727

@@ -52,7 +52,7 @@ There are three types of hooks, init hooks, shutdown hooks and error hooks. Init
5252
require_once __DIR__ . '/../../vendor/autoload.php';
5353

5454
use Utopia\CLI\CLI;
55-
use Utopia\CLI\Console;
55+
use Utopia\Console;
5656
use Utopia\Http\Validator\Wildcard;
5757

5858
CLI::setResource('res1', function() {
@@ -83,78 +83,10 @@ $cli
8383
$cli->run();
8484
```
8585

86-
### Log Messages
87-
88-
```php
89-
Console::log('Plain Log'); // stdout
90-
```
91-
92-
```php
93-
Console::success('Green log message'); // stdout
94-
```
95-
96-
```php
97-
Console::info('Blue log message'); // stdout
98-
```
99-
100-
```php
101-
Console::warning('Yellow log message'); // stderr
102-
```
103-
104-
```php
105-
Console::error('Red log message'); // stderr
106-
```
107-
108-
### Execute Commands
109-
110-
Function returns exit code (0 - OK, >0 - error) and writes stdout, stderr to reference variables. The timeout variable allows you to limit the number of seconds the command can run.
111-
112-
```php
113-
$stdout = '';
114-
$stderr = '';
115-
$stdin = '';
116-
$timeout = 3; // seconds
117-
$code = Console::execute('>&1 echo "success"', $stdin, $stdout, $stderr, $timeout);
118-
119-
echo $code; // 0
120-
echo $stdout; // 'success'
121-
echo $stderr; // ''
122-
```
123-
124-
```php
125-
$stdout = '';
126-
$stderr = '';
127-
$stdin = '';
128-
$timeout = 3; // seconds
129-
$code = Console::execute('>&2 echo "error"', $stdin, $stdout, $stderr, $timeout);
130-
131-
echo $code; // 0
132-
echo $stdout; // ''
133-
echo $stderr; // 'error'
134-
```
135-
136-
### Create a Daemon
137-
138-
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.
139-
140-
```php
141-
<?php
142-
143-
use Utopia\CLI\Console;
144-
145-
include './vendor/autoload.php';
146-
147-
Console::loop(function() {
148-
echo "Hello World\n";
149-
}, 1 /* 1 second */);
150-
```
151-
15286
## System Requirements
15387

15488
Utopia Framework requires PHP 7.4 or later. We recommend using the latest PHP version whenever possible.
15589

156-
157-
15890
## Copyright and license
15991

16092
The MIT License (MIT) [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php)

composer.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,18 @@
1919
"utopia-php/di": "0.1.*"
2020
},
2121
"require-dev": {
22+
"utopia-php/console": "0.0.*",
2223
"phpunit/phpunit": "^9.3",
2324
"squizlabs/php_codesniffer": "^3.6",
2425
"phpstan/phpstan": "^1.10",
2526
"laravel/pint": "1.2.*",
2627
"swoole/ide-helper": "4.8.8"
2728
},
28-
"minimum-stability": "dev"
29-
30-
29+
"minimum-stability": "dev",
30+
"config": {
31+
"allow-plugins": {
32+
"php-http/discovery": true,
33+
"tbachert/spi": true
34+
}
35+
}
3136
}

0 commit comments

Comments
 (0)