Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Binary-safe file write
Alias fputs
fwrite(resource $streamstring $data, ?int $length null): int|false
$basePath $_SERVER['APP_BASE_PATH'] ?? $_ENV['APP_BASE_PATH'] ?? $serverState['octaneConfig']['base_path'] ?? null;



if (! 
is_string($basePath)) {

    
fwrite(STDERR'Cannot find application base path.'.PHP_EOL);



    exit(
11);

}
if (! is_file($autoload_file $basePath.'/vendor/autoload.php')) {

    
fwrite(STDERR"Composer autoload file was not found. Did you install the project's dependencies?".PHP_EOL);



    exit(
10);

}
    {

        if (! 
Str::startsWith($string$this->ignoreMessages)) {

            
$this->output instanceof OutputStyle

                
fwrite(STDERR$string."\n")

                : 
$this->output->writeln($string);

        }

    }
    public static function request(string $methodstring $urlint $statusCodefloat $duration)

    {

        
fwrite(STDOUTjson_encode([

            
'type' => 'request',

            
'method' => $method,

            
'url' => $url,

            
'memory' => memory_get_usage(),

            
'statusCode' => $statusCode,

            
'duration' => $duration,

        ]).
"\n");

    }
            collect($throwable->getTrace())->whereNotNull('file')->first()

            : 
null;



        
fwrite(STDERRjson_encode([

            
'type' => 'throwable',

            
'class' => $throwable::class,

            
'code' => $throwable->getCode(),

            
'file' => $fallbackTrace['file'] ?? $throwable->getFile(),

            
'line' => $fallbackTrace['line'] ?? (int) $throwable->getLine(),

            
'message' => $throwable->getMessage(),

            
'trace' => array_slice($throwable->getTrace(), 02),

        ]).
"\n");

    }
    public static function shutdown(Throwable $throwable)

    {

        
fwrite(STDERRjson_encode([

            
'type' => 'shutdown',

            
'class' => $throwable::class,

            
'code' => $throwable->getCode(),

            
'file' => $throwable->getFile(),

            
'line' => $throwable->getLine(),

            
'message' => $throwable->getMessage(),

            
'trace' => array_slice($throwable->getTrace(), 02),

        ]).
"\n");

    }

}
$basePath = require __DIR__.'/../bin/bootstrap.php';



fwrite(STDOUT$basePath);