silverstripe / sspak

Tool for managing bundles of db/assets from Silverstripe environments
http://silverstripe.github.io/sspak/
BSD 3-Clause "New" or "Revised" License
47 stars 34 forks source link

sspak crashes with autoloader errors #76

Open tractorcow opened 4 years ago

tractorcow commented 4 years ago

When doing the below command

sspak save . myfile.sspak

sspak will crash if you are using any injected dependencies which require the class manifest to load.

This is because sspak will invoke autoload.php, but it will NOT call CoreKernel::bootManifests.

In my case it errors when loading monolog, due to this class not loading.

https://github.com/phptek/silverstripe-sentry/blob/master/_config/config.yml

#!/usr/bin/env php
PHP Fatal error:  Uncaught SilverStripe\Core\Injector\InjectorNotFoundException: ReflectionException: Class PhpTek\Sentry\Handler\SentryMonologHandler does not exist in /Users/damian.mooyman/Sites/tvnz-sales/vendor/silverstripe/framework/src/Core/Injector/InjectionCreator.php:17
Stack trace:
#0 /Users/damian.mooyman/Sites/tvnz-sales/vendor/silverstripe/framework/src/Core/Injector/InjectionCreator.php(17): ReflectionClass->__construct('PhpTek\\Sentry\\H...')
#1 /Users/damian.mooyman/Sites/tvnz-sales/vendor/silverstripe/framework/src/Core/Injector/Injector.php(595): SilverStripe\Core\Injector\InjectionCreator->create('PhpTek\\Sentry\\H...', Array)
#2 /Users/damian.mooyman/Sites/tvnz-sales/vendor/silverstripe/framework/src/Core/Injector/Injector.php(1003): SilverStripe\Core\Injector\Injector->instantiate(Array, 'PhpTek\\Sentry\\H...', 'singleton')
#3 /Users/damian.mooyman/Sites/tvnz-sales/vendor/silverstripe/framework/src/Core/Injector/Injector.php(956): SilverStripe\Core\Injector\Injector->getNamedService('PhpTek\\Sentry\\H...', in /Users/damian.mooyman/Sites/tvnz-sales/vendor/silverstripe/framework/src/Core/Injector/InjectionCreator.php on line 19
Command: /usr/bin/env 'php' '/tmp/sspak-sniffer-341859.php' '.'
Execution failed: returned 255.
Output:

Fatal error: Uncaught SilverStripe\Core\Injector\InjectorNotFoundException: ReflectionException: Class PhpTek\Sentry\Handler\SentryMonologHandler does not exist in /Users/damian.mooyman/Sites/tvnz-sales/vendor/silverstripe/framework/src/Core/Injector/InjectionCreator.php:17
Stack trace:
#0 /Users/damian.mooyman/Sites/tvnz-sales/vendor/silverstripe/framework/src/Core/Injector/InjectionCreator.php(17): ReflectionClass->__construct('PhpTek\\Sentry\\H...')
#1 /Users/damian.mooyman/Sites/tvnz-sales/vendor/silverstripe/framework/src/Core/Injector/Injector.php(595): SilverStripe\Core\Injector\InjectionCreator->create('PhpTek\\Sentry\\H...', Array)
#2 /Users/damian.mooyman/Sites/tvnz-sales/vendor/silverstripe/framework/src/Core/Injector/Injector.php(1003): SilverStripe\Core\Injector\Injector->instantiate(Array, 'PhpTek\\Sentry\\H...', 'singleton')
#3 /Users/damian.mooyman/Sites/tvnz-sales/vendor/silverstripe/framework/src/Core/Injector/Injector.php(956): SilverStripe\Core\Injector\Injector->getNamedService('PhpTek\\Sentry\\H...', in /Users/damian.mooyman/Sites/tvnz-sales/vendor/silverstripe/framework/src/Core/Injector/InjectionCreator.php on line 19
tractorcow commented 4 years ago

I can get around this for the time being by manually adding psr-4 loading to my project root.

"autoload": {
        "psr-4": {
            "App\\": "app/src/",
            "PhpTek\\Sentry\\": "vendor/phptek/sentry/src/",
            "PhpTek\\Sentry\\Monolog\\": "vendor/phptek/sentry/src/"
        },
        "classmap": [
            "app/src/Page.php",
            "app/src/PageController.php"
        ]
    }
tractorcow commented 3 years ago

By the way, if you encounter this issue, sometimes you can "flush" it by running vendor/bin/sake dev/build flush=all