Pop\Project\Install::getBootstrap PHP Метод

getBootstrap() публичный статический Метод

Return the location of the bootstrap file from STDIN
public static getBootstrap ( ) : string
Результат string
    public static function getBootstrap()
    {
        $msg = I18n::factory()->__('Enter the folder where the \'bootstrap.php\' is located in relation to the current folder: ');
        echo $msg;
        $input = null;
        while (!file_exists($input . '/bootstrap.php')) {
            if (null !== $input) {
                echo I18n::factory()->__('Bootstrap file not found. Try again.') . PHP_EOL . $msg;
            }
            $prompt = fopen("php://stdin", "r");
            $input = fgets($prompt, 255);
            $input = rtrim($input);
            fclose($prompt);
        }
        return $input;
    }

Usage Example

Пример #1
0
         // Else, check if the source folder exists
     } else {
         if (!file_exists($argv[2])) {
             echo Install::cliError(2);
             // Else, check if the output file ends in '.php'
         } else {
             if (strtolower(substr($argv[3], -4)) != '.php') {
                 echo Install::cliError(3);
                 // Else, generate the class map file
             } else {
                 echo 'Generating class map file \'' . $argv[3] . '\' from source folder \'' . $argv[2] . '\'' . PHP_EOL;
                 Classmap::generate($argv[2], $argv[3]);
                 // Add project to the bootstrap file
                 $input = Install::cliInput('Add classmap to the bootstrap file? (Y/N) ');
                 if ($input == 'y') {
                     $location = Install::getBootstrap();
                     $bootstrap = new File($location . '/bootstrap.php');
                     $bootstrap->write("\$autoloader->loadClassMap('" . addslashes(realpath($argv[3])) . "');" . PHP_EOL . PHP_EOL, true)->save();
                 }
                 echo 'Done.' . PHP_EOL . PHP_EOL;
             }
         }
     }
     // Else, install project
 } else {
     if ($argv[1] == '-i' || $argv[1] == '--install') {
         // Check if the project install file argument was passed
         if (empty($argv[2])) {
             echo Install::cliError(4);
             // Else, run the install process
         } else {