laravel-self-diagnosis icon indicating copy to clipboard operation
laravel-self-diagnosis copied to clipboard

Checker for php.ini options

Open akalongman opened this issue 6 years ago • 8 comments

For my project I've implemented checker for php.ini options. Configuration looks like this:

\App\Libraries\SelfDiagnosis\Checks\PhpIniOptions::class                  => [
    'options' => [
        'upload_max_filesize' => '>=128M',
        'post_max_size'       => '>=128M',
        'memory_limit'        => '>=128M',
        'max_input_vars'      => '>=10000',
        'file_uploads'        => '1',
        'disable_functions'   => '',
    ],
],

If project owners will be interested, I can send PR

akalongman avatar Jan 17 '19 09:01 akalongman

@mpociot any thoughts?

akalongman avatar Feb 14 '19 14:02 akalongman

I would like to see this added.

HDVinnie avatar Feb 17 '19 06:02 HDVinnie

There can be an issue of checking it, as the command will be run in cli, and for requests, fpm is used. But probably it is feasible, just less obvious to implement 🤷‍♂️

alexsoft avatar Mar 25 '19 16:03 alexsoft

There can be an issue of checking it, as the command will be run in cli

I run it in HTTP via $kernel->call() from controller

akalongman avatar Mar 26 '19 11:03 akalongman

@akalongman Can you please tell how are you using $kernel->call(). I cannot figure out how I use that with ini_get('max_execution_time') for example.

sarfraznawaz2005 avatar Jul 26 '19 12:07 sarfraznawaz2005

@sarfraznawaz2005 You have to run

$output = new BufferedOutput(
    OutputInterface::VERBOSITY_NORMAL,
    true,
);

$kernel->call('self-diagnosis', [], $output)

($kernel is Illuminate\Contracts\Console\Kernel)

akalongman avatar Jul 26 '19 12:07 akalongman

@akalongman Thanks. As @alexsoft pointed out we should use http kernel instead of console kernel to get correct php ini value which is expected on web (http). So not sure how I can I get value for ini_get('max_execution_time') which comes from php.ini used for web not for console (a different php.ini file is used by server for cli).

sarfraznawaz2005 avatar Jul 26 '19 12:07 sarfraznawaz2005

@akalongman okay so this can return php.ini flags used for web/http: $values = parse_ini_file(php_ini_loaded_file());

Thanks

sarfraznawaz2005 avatar Jul 27 '19 11:07 sarfraznawaz2005