What is the Spark CLI in CodeIgniter 4?
Why Interviewers Ask This
Interviewers use this question to quickly assess whether a candidate has the foundational knowledge required for CodeIgniter development. It reveals whether you understand the building blocks that more complex concepts rely on.
Answer
Spark is CodeIgniter 4's command-line tool, similar to Laravel's Artisan. Run commands with php spark <command>. Built-in commands: php spark serve (start dev server on port 8080), php spark migrate (run migrations), php spark db:seed SeedName (run a seeder), php spark make:controller UserController (generate a controller), php spark make:model UserModel (generate a model), php spark make:filter AuthFilter (generate a filter), php spark make:seeder UserSeeder. List all commands: php spark list. Create custom Spark commands by extending CodeIgniter\CLI\BaseCommand and placing the file in app/Commands/. Custom commands must define $group, $name, $description, and a run() method.
Pro Tip
Demonstrate both theoretical understanding and practical experience. Say what it is, then give an example of how you actually used it in a CodeIgniter codebase.
Previous
What are Services in CodeIgniter 4?
Next
What is the difference between CodeIgniter 3 and CodeIgniter 4?