PHP Version
8.2
CodeIgniter4 Version
4.4.1 and develop
CodeIgniter4 Installation Method
Composer (using codeigniter4/appstarter)
Which operating systems have you tested for this bug?
macOS
Which server did you use?
cli
Database
irrelevant
What happened?
I'm not able to use any named route when running CLI.
Steps to Reproduce
In Routes.php I declared a named route:
$routes->get('sample-url-1', 'HomeController::index', ['as' => 'sample1']);
And then, I created a sample command:
namespace App\Commands;
use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;
class Sample extends BaseCommand
{
/**
* The Command's Group
*
* @var string
*/
protected $group = 'Sample';
/**
* The Command's Name
*
* @var string
*/
protected $name = 'sample:command';
/**
* The Command's Description
*
* @var string
*/
protected $description = 'Sample command';
/**
* The Command's Usage
*
* @var string
*/
protected $usage = 'sample';
/**
* The Command's Arguments
*
* @var array
*/
protected $arguments = [];
/**
* The Command's Options
*
* @var array
*/
protected $options = [];
/**
* Actually execute a command.
*
* @param array $params
*/
public function run(array $params)
{
CLI::write('site_url: ' . site_url('sample1'), 'blue');
CLI::write('url_to: ' . url_to('sample1'), 'blue');
CLI::write('route_to: ' . route_to('sample1'), 'blue');
}
}
Now, when I run php spark sample:command only the first CLI::write is displayed. Then I get the error:
{
"title": "CodeIgniter\\Router\\Exceptions\\RouterException",
"type": "CodeIgniter\\Router\\Exceptions\\RouterException",
"code": 500,
"message": "The route for \"sample1\" cannot be found.",
"file": "/Users/michalsn/Sites/ci441/vendor/codeigniter4/codeigniter4/system/Helpers/url_helper.php",
"line": 489,
...
Expected Output
Displaying all URLs
Anything else?
No response
PHP Version
8.2
CodeIgniter4 Version
4.4.1 and develop
CodeIgniter4 Installation Method
Composer (using
codeigniter4/appstarter)Which operating systems have you tested for this bug?
macOS
Which server did you use?
cli
Database
irrelevant
What happened?
I'm not able to use any named route when running CLI.
Steps to Reproduce
In
Routes.phpI declared a named route:And then, I created a sample command:
Now, when I run
php spark sample:commandonly the firstCLI::writeis displayed. Then I get the error:Expected Output
Displaying all URLs
Anything else?
No response