Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Binary-safe file write
Alias fputs
<?php fwrite(resource $stream, string $data, ?int $length = null): int|false
<?php $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);

}
<?php 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);

}
<?php     {

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

            $this->output instanceof OutputStyle

                ? fwrite(STDERR, $string."\n")

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

        }

    }
<?php     public static function request(string $method, string $url, int $statusCode, float $duration)

    {

        fwrite(STDOUT, json_encode([

            'type' => 'request',

            'method' => $method,

            'url' => $url,

            'memory' => memory_get_usage(),

            'statusCode' => $statusCode,

            'duration' => $duration,

        ])."\n");

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

            : null;



        fwrite(STDERR, json_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(), 0, 2),

        ])."\n");

    }
<?php     public static function shutdown(Throwable $throwable)

    {

        fwrite(STDERR, json_encode([

            'type' => 'shutdown',

            'class' => $throwable::class,

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

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

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

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

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

        ])."\n");

    }

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



fwrite(STDOUT, $basePath);