Spark is CodeIgniter 4's command-line tool. Run it from the project folder with php spark <command>.
Everyday commands
php spark list— all commandsphp spark serve— development serverphp spark routes— every route and its controllerphp spark env— show the current environment
Generators
make:controller Blog(add--restfulfor a REST controller)make:model BlogModelmake:migration CreateBlogTablemake:seeder BlogSeedermake:filter AuthFiltermake:entity Blogmake:command SendReport— your own spark commandmake:scaffold Blog— controller, model, migration, seeder together
Database
migrate,migrate:rollback,migrate:statusdb:seed BlogSeederdb:table posts— show a table's rows and fields
Other
cache:clear— clear the cachekey:generate— set the encryption key in.env
Add --help after any command to see its options.
Example
Example — Generate files with spark
Bash
# See every route
php spark routes
# Create a model with matching files
php spark make:model PostModel
# File created: APPPATH/Models/PostModel.php
# Controller, model, migration and seeder in one go
php spark make:scaffold Post
# Run migrations and check their status
php spark migrate
php spark migrate:status
# Clear the cache
php spark cache:clear
Each make: command creates a ready-to-edit file in the right app folder with the correct namespace.