Search code examples
phpcomposer-phprequire

require of a file with return value fails silently.


I have two simple files (+those generated and downloaded by composer)

I have a simple php file:

<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);

require __DIR__ . '/vendor/composer/autoload_classmap.php';

echo 'OK';

where autoload_classmap.php is generated based on this composer.json:

{
  "require-dev": {
    "symplify/easy-coding-standard": "5.3.*"
  },
  "config": {
    "optimize-autoloader": true
  }
}

But php script fails on the line with require. There's no error, no data are returned. Browser shows only ERR_CONNECTION_RESET.

(specific package in composer is probably irrelevant, I picked it because it has quite a lot of dependencies)

The problem is in the size of the required file (maybe not in the absolute size of the file but number of rows in array that's being returned definitively plays a role), if I delete number of rows down to around 1600 (I wasn't able to determine exact number - length of individual rows probably factors in).

I think this problem isn't really connected to composer itself though when I tried to replace array of classes with much larger array of random long text it worked fine.

The problem is (most probably) platform dependent: I tried it on my server and it worked fine but when I run it locally on a machine using Windows + WAMPServer (tested on two different machines) through web browser it fails with aforementioned disconnect error. It fails both in Chrome and Edge.

I run Windows 10, PHP 7.2.12 (but tested with 7.3 as well), Apache 2.4.37

On the other hand, when running through CLI it again works fine - so I don't think there's problem with some specific setting in php. But again - probably, what do I know? :)

I tried to find reasons why require may silently fail but I wasn't able to find anything. And I'm out of ideas hot to get it working. Framework I use in my real app relies on requiring this file and for that reason I need to keep optimize-autoloader on false (simply because that way it'll generate much smaller file and require works)

Any ideas?

Thanks


Solution

  • Turns out apache logged this notice:

    [mpm_winnt:notice] [pid 6696:tid 672] AH00428: Parent: child process 14924 exited with status 3221225725 -- Restarting.
    

    which directed me to this solution: https://www.codexpedia.com/apache-server/parent-child-process-exited-with-status-3221225725-restarting-on-xamp-apache/

    All I needed to do was to add this:

    <IfModule mpm_winnt_module>
       ThreadStackSize 8888888
    </IfModule>
    

    in the httpd.conf file.