21 lines
		
	
	
		
			507 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
		
		
			
		
	
	
			21 lines
		
	
	
		
			507 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| 
								 | 
							
								<?php
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								use React\EventLoop\Loop;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								require_once __DIR__."/vendor/autoload.php";
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								$shell = new NoccyLabs\React\Shell\Shell();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								$shell->on('prompt', function () use ($shell) { 
							 | 
						||
| 
								 | 
							
								    $shell->setPrompt(date("H:i:s> ")); 
							 | 
						||
| 
								 | 
							
								});
							 | 
						||
| 
								 | 
							
								$shell->on('input', function (array $input) use ($shell) {
							 | 
						||
| 
								 | 
							
								    $shell->write("You entered: ".join(" ", $input)."\n");
							 | 
						||
| 
								 | 
							
								});
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// The shell is an OutputStream
							 | 
						||
| 
								 | 
							
								$shell->write("Hello World!\n\n");
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								Loop::addPeriodicTimer(5, function () use ($shell) {
							 | 
						||
| 
								 | 
							
								    $shell->write(date(DATE_ATOM)."\n");
							 | 
						||
| 
								 | 
							
								});
							 |