0

I am trying to se Laravel background. I have followed the official doc for creating it, Job file:

    public function handle(){

    $fileGet = file_get_contents ('https://dummyimage.com/600x400/000/fff');
    return;
}

public function failed($exception)
{
    shell_exec(" php -i | grep 'Configuration File'");
    $fp = file_put_contents (base_path() . '/errors.txt', get_cfg_var('cfg_file_path'));
}

I am using simple file_get_contents. This job is executed through HTTP request, when I access specific URL, Controller action:

CustomJob::dispatch();

, but I am getting this error:

ErrorException: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /.../CustomJob.php:45

Everywhere in the hosting (shared) this option is enabled and I can use it WITHOUT Background jobs. The problem is when I use it in background job. The errors.file says about php.ini file - /opt/cpanel/ea-php72/root/etc/php.ini

Now, I am using php 7.3 with local (for the home dir) php.ini file.

I even can't debug that error, but how background job uses another php.ini file and is there a way to set the correct php.ini file ?

1 Answer 1

2

Background jobs are probably fired using a seprate PHP CLI installation. Those are configured with separate php.ini files. You should try editing that one instead.

7
  • How, I can't understand ?
    – gdfgdfg
    Jul 4, 2019 at 20:37
  • That depends on what your shared hosting offers you. Can you access the server via ssh? Can you adjust the php.ini config that way? Otherwise can you change the php.ini config in the control panel of your hosting?
    – PtrTon
    Jul 4, 2019 at 21:37
  • Yes, I have accces. In cPanel this option is enabled.
    – gdfgdfg
    Jul 4, 2019 at 21:43
  • Do you have access to a single php.ini config or two php.ini configs in cPanel. You will most likely only have acces to one; the one being used to serve web requests. The php.ini configuration which is used on the command line is the one you want, can you also access that one?
    – PtrTon
    Jul 4, 2019 at 21:52
  • I have access in cPanel to local php.ini which is in my home dir
    – gdfgdfg
    Jul 4, 2019 at 22:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.