Anyone?
Script php artisan optimize handling the post-update-cmd event returned with error code 255
I am getting an error when I run composer update:
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined function apache_request_headers()
Script php artisan optimize handling the post-update-cmd event returned with error code 255
Problem is in my custom error handler, loaded through a service provider:
private function include_request_headers()
{
// Include request headers in log entry
if( $request_headers = \apache_request_headers() )
{
$this->log_entry .= 'Request headers:' . PHP_EOL;
foreach( $request_headers as $k => $v )
{
$this->log_entry .= "\t" . $k . ' = ' . $v . PHP_EOL;
}
}
}
Service Provider:
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use App\Exceptions\CustomErrorHandler;
use App;
class CustomErrorHandlingProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* This section waits until all of the service providers
* have been registered in the register method.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
if( App::environment('local', 'production') )
{
error_reporting(0);
new CustomErrorHandler;
}
}
}
I realize that this may not be proper usage of a service provider, since I'm not actually binding something to the container.
The apache_request_headers function definitely exists on my server. I had to add the backslash in front of it, because without it the error above thinks apache_request_headers is part of the App\Exceptions namespace.
I did move the loading of this service provider to the top of the stack in config/app.php, because I want to have it load as soon as possible. If I comment out the section that is throwing the error, composer update works fine, and even with uncommenting the error handler works fine too.
Any idea why this error is happening?
Please or to participate in this conversation.