Welcome Guest, Not a member yet? Register   Sign In
Spark Command not Listed/Registered
#1

I have successfully created 2 Spark CLI commands. However when I create a third it fails to get listed by the "php spark list" command. I cloned the new command from an existing working one and have checked that there are no code errors. So I can't see what the problem is.
The output of "php spark list" looks like:
Code:
. . .
Shield
  shield:model      Generate a new UserModel file.
  shield:setup      Initial setup for CodeIgniter Shield.

demo
  app:info          Displays basic application information.

tools
  users:addadmins    Add Laura Fair committee members as admins.
murray@Blackie:/webapps/applications$
The contents of my /Commands directory:
Code:
murray@Blackie:/webapps/applications/app/Commands$ ls -lah
total 20K
drwxrwxr-x  2 murray murray 4.0K Jun  6 09:08 .
drwxrwxr-x 14 murray murray 4.0K Jun  4 13:48 ..
-rw-rw-r--  1 murray murray 2.1K Jun  4 14:58 AddCommitteeUsers.php
-rw-rw-r--  1 murray murray  805 Jun  4 13:51 AppInfo.php
-rw-rw-r--  1 murray murray  380 Jun  6 09:08 DeleteCommitteeUsers.php
murray@Blackie:/webapps/applications/app/Commands$
The code for the DeleteCommitteeUsers.php command:
Code:
<?php

namespace App\Commands;

use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;
use CodeIgniter\Shield\Entities\User;

class DelCommitteeUsers extends BaseCommand
{
    protected $group      = 'tools';
    protected $name        = 'users:deladmins';
    protected $description = 'Delete Laura Fair committee admins.';

    public function run(array $params) {

    }
}

I can't see any substantive difference between this and the working command which looks like:
Code:
<?php

namespace App\Commands;

use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;
use CodeIgniter\Shield\Entities\User;

class AddCommitteeUsers extends BaseCommand
{
    protected $group      = 'tools';
    protected $name        = 'users:addadmins';
    protected $description = 'Add Laura Fair committee members as admins.';

    public function run(array $params) {
. . .

Also is there an error log for "php spark"? Wondering if there's perhaps an error getting thrown which I can't see. I did have problems with commands not being listed when I had a typo in the code which would throw a PHP error. However I have checked this command as best I can and don't think it has an errors.
Any help would be much appreciated.

Reply
#2

Turns out code errors will be shown by "php spark":

murray@Blackie:/webapps/applications$ php spark list

CodeIgniter v4.3.5 Command Line Tool - Server Time: 2023-06-06 01:00:00 UTC+00:00


[ParseError]

Unclosed '{' on line 27 does not match ')'

at APPPATH/Commands/AddCommitteeUsers.php:43

Backtrace:
1 SYSTEMPATH/Autoloader/Autoloader.php:289
CodeIgniter\Autoloader\Autoloader()->includeFile()
Reply




Theme © iAndrew 2016 - Forum software by © MyBB