output.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. require dirname(__DIR__) . '/vendor/autoload.php';
  3. use Michel\Console\Output;
  4. $output = new Output();
  5. $console = new Output\ConsoleOutput($output);
  6. $data = [
  7. 'name' => 'John Doe',
  8. 'email' => 'john.doe@example.com',
  9. 'active' => true,
  10. 'roles' => ['admin', 'user']
  11. ];
  12. $console->json($data);
  13. //
  14. $console->spinner();
  15. $message = "This is a long message that needs to be automatically wrapped within the box, so it fits neatly without manual line breaks.";
  16. $console->boxed($message);
  17. $console->boxed($message, '.', 2);
  18. $console->success('The deployment was successful! All application components have been updated and the server is running the latest version. You can access the application and check if all services are functioning correctly.');
  19. $console->success('The deployment was successful! All application components have been updated and the server is running the latest version.');
  20. $console->warning('Warning: The connection to the remote server is unstable! Several attempts to establish a stable connection have failed, and data integrity cannot be guaranteed. Please check the network connection.');
  21. $console->warning('Warning: You are attempting to run a script with elevated privileges!');
  22. //
  23. $console->info('Info: Data export was completed successfully! All requested records have been exported to the specified format and location. You can now download the file or access it from the application dashboard.');
  24. $console->info('Info: Data export was completed successfully!');
  25. $console->error('Critical error encountered! The server encountered an unexpected condition that prevented it from fulfilling the request.');
  26. $console->title('My Application Title');
  27. $items = ['First item', 'Second item', 'Third item'];
  28. $console->list($items);
  29. $console->numberedList($items);
  30. $items = [
  31. 'Main Item 1',
  32. ['Sub-item 1.1', 'Sub-item 1.2'],
  33. 'Main Item 2',
  34. ['Sub-item 2.1', ['Sub-sub-item 2.1.1']]
  35. ];
  36. $console->indentedList($items);
  37. $console->writeln('');
  38. $options = [
  39. 'Username' => 'admin',
  40. 'Password' => '******',
  41. 'Server' => 'localhost',
  42. 'Port' => '3306'
  43. ];
  44. $console->listKeyValues($options);
  45. $headers = ['ID', 'Name', 'Status'];
  46. $rows = [
  47. ['1', 'John Doe', 'Active'],
  48. ['2', 'Jane Smith', 'Inactive'],
  49. ['3', 'Emily Johnson', 'Active']
  50. ];
  51. $console->table($headers, $rows);
  52. for ($i = 0; $i <= 100; $i++) {
  53. $console->progressBar(100, $i);
  54. usleep(8000); // Simulate some work being done
  55. }
  56. if ($console->confirm('Are you sure you want to proceed ?')) {
  57. $console->success('Action confirmed.');
  58. } else {
  59. $console->error('Action canceled.');
  60. }
  61. $name = $console->ask('What is your name ?');
  62. $console->success("Hello, $name!");
  63. $password = $console->ask('Enter your demo password', true, true);
  64. $console->success("Your password is: $password");
  65. $console->success('Done!');