03-31-2021, 08:28 AM
(This post was last modified: 03-31-2021, 08:46 AM by simonickalexs.)
I'm trying to test to make my own CLI command on my own library but it throw error cannot declare `someone\plugin\Commands` because the class name is already in use. Here's the source code.
Can someone explain why? Thank you.
Edit: I put it on the ThirdParty folder. Full path is on "ThirdParty\trydummy\src".
PHP Code:
<?php
namespace someone\plugin\Commands;
use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;
class PrintHelloWorld extends BaseCommand
{
/**
* The Command's Group
*
* @var string
*/
protected $group = 'Testing';
/**
* The Command's Name
*
* @var string
*/
protected $name = 'print:dummy';
/**
* The Command's Description
*
* @var string
*/
protected $description = 'Print Hello World';
/**
* The Command's Usage
*
* @var string
*/
protected $usage = 'print:dummy [options]';
/**
* The path to someone\src directory.
*
* @var string
*/
protected $sourcePath;
/**
* The command's options
*
* @var array
*/
protected $options = [];
/**
* Actually execute the command.
*
* @param array $params
*
* @return void
*/
public function run(array $params)
{
CLI::write('Hello world!.', 'green');
}
}
Can someone explain why? Thank you.
Edit: I put it on the ThirdParty folder. Full path is on "ThirdParty\trydummy\src".