PHP code example of isublimity / shell

1. Go to this page and download the library: Download isublimity/shell library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

isublimity / shell example snippets




class xyzActions
{
   /**
       * Получить список бла-бла
       *
       * @param string $name Назврание
       * @param bool $reg включить или выключить
       * @return array
       */
      public function listCommand($name,$reg=false)
      {
          echo "My name $name ";
          if ($reg) echo " ;) ";
          echo "\n";
      }
}



\Shell::name("xyz");
\Shell::run(
         new xyzActions()
     );



Shell::msg("ABC <light_blue> FGHJ </light_blue> Command();");

Shell::msg("message");

Shell::debug("DEBUG!");

Shell::info("INFO!");

Shell::warning("WARN!");

Shell::error("ERORR!!");


class xyzActions
{
    public function getTitle()
    {
        return 'ABOUTE xyzActions - <red>XYZ</red>';
    }
}

class xyzActions
{
    public function setColor($value)
    {
        echo "CALL setColor($value)\n";
    }
}

Автоматически вызовется если : > php test.php --color=YXA



// Блокирует исполнение 
Shell::maxExecutionMinutes(0.5);//30 seconds 


Shell::dir(__DIR__); // сменить директорию 
Shell::alertMail('[email protected]'); // куда отпраить ошибки
Shell::setPathLog("/tmp/");   // куда записывать все сообщения 
Shell::setPathPid("/tmp/");   // где PID 
Shell::setExitCodeOnPidExists(2);   // Exit code on PID file Exists
Shell::setPidCommands(array('check','test')); // какие комманды можно запускать одновренменно