BrianHenryIE / strauss

Prefix PHP namespaces and classnames to allow multiple versions of libraries to exist without conflict.
https://brianhenryie.github.io/strauss/
MIT License
137 stars 21 forks source link

Still stuck at "Performing replacements..." #86

Closed sovetski closed 6 months ago

sovetski commented 6 months ago

I just used the documentation's composer example, and it stuck at the "[info] Performing replacements..." step

Edit: I just got this error

The following exception is caused by a process timeout
Check https://getcomposer.org/doc/06-config.md#process-timeout for details

In Process.php line 1204:

  The process "strauss" exceeded the timeout of 300 seconds.  

Very strange, I have only 1 dependency and it is very very slow...

My composer.json:

{
    "require": {        
        "aws/aws-sdk-php": "^3.257"
    },
    "require-dev": {
        "brianhenryie/strauss": "^0.16.0"
    },
    "scripts": {
        "prefix-namespaces": [
            "strauss"
        ],
        "post-install-cmd": [
            "@prefix-namespaces"
        ],
        "post-update-cmd": [
            "@prefix-namespaces"
        ]
    },
    "extra": {
        "strauss": {
            "namespace_prefix": "MyCustomTest\\",
            "classmap_prefix": "MyCustomTest_"
        }
    }
}
BrianHenryIE commented 6 months ago

The AWS SDK is enormous – it's 216,273 PHP files to require aws/aws-sdk-php. Their repo has instructions for Removing Unused Services. Then with fewer files, this tool should run in a reasonable time.

The timeout you're experiencing can be fixed by following the instructions linked in the error message, or running the tool directly with vendor/bin/strauss.

There's nothing here that's not working, per se.

$ date; vendor/bin/strauss; date
Wed Mar  6 14:22:13 PST 2024
[info] Loading config...
[info] Building dependency list...
[info] Enumerating files...
[info] Copying files...
[info] Determining changes...
[info] Performing replacements...
[info] Adding licenses...
[info] Generating autoloader...
[info] Cleaning up...
Wed Mar  6 14:27:40 PST 2024

There is a branch started with the idea of enumerating all changes before performing them. By taking that approach, it should be possible to remove some of the the loops in loops. In theory it should be O(n) – two passes over all the files.

sovetski commented 6 months ago

Thanks @BrianHenryIE, Removing unused services was very helpful, it is very quick now, but I have another problem, I will create a new issue