Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoload Issue #11960

Open
piercesteven12 opened this issue May 3, 2024 · 5 comments
Open

Autoload Issue #11960

piercesteven12 opened this issue May 3, 2024 · 5 comments
Labels

Comments

@piercesteven12
Copy link

Fatal error: Uncaught Error: Class "App\Controllers\AuthenticationController" not found in /storage/ssd5/860/22112860/public_html/requests/transaction/authenticate.action.php:10 Stack trace: #0 {main} thrown in /storage/ssd5/860/22112860/public_html/requests/transaction/authenticate.action.php on line 10

It is working just fine in my vs code, but when I deploy my project in 000webhost, my classes are not found. How do I solve this issue?

@Seldaek
Copy link
Member

Seldaek commented May 3, 2024

You need to provide some information like at least your composer.json's autoload config..

@dugwood
Copy link

dugwood commented May 4, 2024

Having an issue with 2.7.5 too, 2.7.4 (and previous) were working fine. Seems to be the same issue, here's my error:

Fatal error: Uncaught TypeError: Composer\EventDispatcher\EventDispatcher::getCallbackIdentifier(): Argument #1 ($cb) must be of type callable, array given, called in phar:///home/test/composer/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php on line 419 and defined in phar:///home/test/composer/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:664
Stack trace:
#0 phar:///home/test/composer/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php(419): Composer\EventDispatcher\EventDispatcher->getCallbackIdentifier()
#1 phar:///home/test/composer/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php(115): Composer\EventDispatcher\EventDispatcher->doDispatch()
#2 phar:///home/test/composer/composer.phar/src/Composer/Factory.php(448): Composer\EventDispatcher\EventDispatcher->dispatch()
#3 phar:///home/test/composer/composer.phar/src/Composer/Factory.php(629): Composer\Factory->createComposer()
#4 phar:///home/test/composer/composer.phar/src/Composer/Console/Application.php(549): Composer\Factory::create()
#5 phar:///home/test/composer/composer.phar/src/Composer/Console/Application.php(483): Composer\Console\Application->getComposer()
#6 phar:///home/test/composer/composer.phar/src/Composer/Console/Application.php(430): Composer\Console\Application->hintCommonErrors()
#7 phar:///home/test/composer/composer.phar/vendor/symfony/console/Application.php(171): Composer\Console\Application->doRun()
#8 phar:///home/test/composer/composer.phar/src/Composer/Console/Application.php(148): Symfony\Component\Console\Application->run()
#9 phar:///home/test/composer/composer.phar/bin/composer(93): Composer\Console\Application->run()
#10 /home/test/composer/composer.phar(29): require('...')
#11 {main}
  thrown in phar:///home/test/composer/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php on line 664

It happens for every call of composer.phar, whatever the arguments. And only with an autoprepend file with homemade autoloader. Disabling my autoloader solves the issue.

So clearly an issue in autoloading.

@dugwood
Copy link

dugwood commented May 4, 2024

To build upon previous notes:

  • @piercesteven12 issue must come from the reordering of autoloaders (which breaks the order his code expect the autoloaders)
    • for example, say there's a list of autoloaders: AL1, AL2, composer, AL3, AL4
    • the way composer rewrites the list is: composer, AL3, AL4, AL1, AL2
  • my issue is that my Autoloader isn't callable, but it works as expected... so maybe I'm missing a PHP declaration or something like that.
    • [EDIT] I was passing a private method to spl_autoload_register(), which works but is_callable() returns false (as it's not directly callable by an external code)
    • I think other people may face the same issue, perhaps removing the callable could be an option. Or add a warning that it's bad practice to have a private register function (which works)

@Seldaek
Copy link
Member

Seldaek commented May 4, 2024

Right I'll fix that ASAP, thanks for figuring it out.

@Seldaek
Copy link
Member

Seldaek commented May 4, 2024

@dugwood Your issue is fixed in c2fd4d3 and now released as 2.7.6. The original issue here is unrelated though I believe as your problem was purely a composer runtime thing, and the OP seems to be having problem in their application autoloading, not while composer runs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants