Welcome Guest, Not a member yet? Register   Sign In
Class "Composer\Command\BaseCommand" not found
#1

I'm using pest framework for testing, however, when pest is installed, the subject of this thread prevent `php spark` command to run. Trace:
Code:
CodeIgniter v4.2.4 Command Line Tool - Server Time: 2022-08-21 16:36:53 UTC-05:00


[Error]

Class "Composer\Command\BaseCommand" not found

at VENDORPATH\pestphp\pest-plugin\src\Commands\DumpCommand.php:15

Backtrace:
  1    SYSTEMPATH\Autoloader\Autoloader.php:282
      include_once()

  2    SYSTEMPATH\Autoloader\Autoloader.php:259
      CodeIgniter\Autoloader\Autoloader()->includeFile('C:\\laragon\\www\\project\\vendor\\composer/../pestphp/pest-plugin/src\\Commands\\DumpCommand.php')

  3    SYSTEMPATH\Autoloader\Autoloader.php:237
      CodeIgniter\Autoloader\Autoloader()->loadInNamespace('Pest\\Plugin\\Commands\\DumpCommand')

  4    [internal function]
      CodeIgniter\Autoloader\Autoloader()->loadClass('Pest\\Plugin\\Commands\\DumpCommand')

  5    SYSTEMPATH\CLI\Commands.php:101
      class_exists('Pest\\Plugin\\Commands\\DumpCommand')

  6    SYSTEMPATH\CLI\Commands.php:46
      CodeIgniter\CLI\Commands()->discoverCommands()

  7    SYSTEMPATH\Config\Services.php:162
      CodeIgniter\CLI\Commands()->__construct()

  8    SYSTEMPATH\Config\BaseService.php:253
      CodeIgniter\Config\Services::commands(false)

  9    SYSTEMPATH\Config\BaseService.php:194
      CodeIgniter\Config\BaseService::__callStatic('commands', [...])

10    SYSTEMPATH\Config\Services.php:159
      CodeIgniter\Config\BaseService::getSharedInstance('commands')

11    SYSTEMPATH\Config\BaseService.php:253
      CodeIgniter\Config\Services::commands()

12    SYSTEMPATH\CLI\CommandRunner.php:35
      CodeIgniter\Config\BaseService::__callStatic('commands', [])

13    SYSTEMPATH\CodeIgniter.php:866
      CodeIgniter\CLI\CommandRunner()->__construct()

14    SYSTEMPATH\CodeIgniter.php:448
      CodeIgniter\CodeIgniter()->createController()

15    SYSTEMPATH\CodeIgniter.php:336
      CodeIgniter\CodeIgniter()->handleRequest(null, Object(Config\Cache), false)

16    SYSTEMPATH\CLI\Console.php:48
      CodeIgniter\CodeIgniter()->run()

17    ROOTPATH\spark:98
      CodeIgniter\CLI\Console()->run()
Reply
#2

Config\Modules::$discoverInComposer = false
Reply
#3

Is this a bug in pest?
Reply
#4

@kenjis This is a framework bug.
If the search for modules in the composer is enabled in the config, the namespaces of the installed packages are saved.
When searching for a command, all namespaces are checked and Commands/ is appended to the namespace directory path.
Therefore, the VENDORPATH\pestphp\pest-plugin\src\Commands\ directory is scanned.

The Composer\Command\BaseCommand namespace is Composer's internal namespace, and as I understand it (not sure) it is available only when accessing composer.phar, that is, through the CLI.
Therefore, an error occurs.

I believe that this is not only related to commands.
If the composer package contains a Config directory with {Routes, Events, Services, Filters, Registrar}.php files or a Helpers/{helpername}.php directory

This may break the application.
Reply
#5

(09-03-2022, 05:18 AM)iRedds Wrote: The Composer\Command\BaseCommand namespace is Composer's internal namespace, and as I understand it (not sure) it is available only when accessing composer.phar, that is, through the CLI.
Therefore, an error occurs.

The package is a Composer plugin?
So it depends on Composer\Command\BaseCommand.
Yes, the class is not accessible from spark.
Reply
#6

Since v4.3, you can configure Composer packages to discover manually.
See https://github.com/codeigniter4/CodeIgniter4/pull/6503
Reply




Theme © iAndrew 2016 - Forum software by © MyBB