After this lesson you can use Spark to inspect commands, generate a controller skeleton and confirm the routes your application actually exposes. Run commands from the disposable bookshop's project root, where the spark file is present. A command typed from the parent folder does not automatically know which application you intend to inspect.
Spark runs inside the application context
Spark is CodeIgniter's command-line entry point. It provides discovery commands and commands that change files or data. Knowing which category a command belongs to is part of using it responsibly. Reading a route list is different from rolling back a database migration, even though both begin with the same executable name.
php spark list
php spark help make:controller
php spark routesThese commands were run against the installed application. The official Spark Commands guide documents command discovery and help. Reading help before adding a flag is more reliable than guessing from another framework's command syntax. CodeIgniter uses Spark; a command beginning with another framework's launcher should not be silently substituted.
The route report contains a method, route pattern, handler and filter columns. It also reports required filters separately. Read the whole relevant report rather than assuming an empty route-specific filter column means no framework filter runs at all. The starter had required filters even before our custom route checks were added.
Generate a skeleton deliberately
A generator writes a starting file, not finished business behavior. We used a disposable Probe controller to verify the command without overwriting the Books controller that the course will build.
php spark make:controller Probe
php -l app/Controllers/Probe.phpExample output captured on 2026-11; yours will differ. The timestamped Spark banner is omitted.
File created: APPPATH/Controllers/Probe.php
No syntax errors detected in app/Controllers/Probe.phpPHP's lint check confirms syntax. It does not prove that a route reaches the controller or that its action produces the right result. These are different checks, and the course will use both. Do not interpret a clean lint report as evidence that a database query or authorization rule is correct.
The generated filename and class name should match. Open the file and identify its namespace, parent class and method before changing anything. You can keep Probe as an unreferenced local experiment, but do not add it to a public route map unless it has a purpose. An unused learning file is not automatically a browser endpoint when auto routing is disabled.
Inspect before changing persistent state
Later you will use migration and seeding commands. A migration changes the schema; a seeder writes records. Repeating a simple inserting seeder can create more rows. A refresh command can roll back and rebuild tables, which is destructive to data. These actions are appropriate only in a disposable learning database unless a reviewed operational plan says otherwise.
Spark's command list also includes cache and logging operations. A command that clears information can destroy useful troubleshooting evidence. Before running one, decide what information you need to retain and whether the current application is the intended target. In this course the target is always the isolated bookshop.
Use help as a version check
The controller generator's help in 4.7.6 listed options including bare, restful, namespace, suffix and force. We do not need those options to create Probe. In particular, do not add force casually: overwriting a file is a different decision from generating a new one. When a tutorial uses an option you cannot find in your installed help, compare versions before proceeding.
The official Spark Commands guide was fetched for this course. Our command output comes from the actual installed 4.7.6 application. The combination gives you both a documented meaning and a local observation. Neither guarantees the same command is safe in a different application's database context.
Build a useful command notebook
Record a command together with its working directory, intent and observed result. A note saying “routes showed only the starter home action” is more informative than a screenshot with no context. Once we add books routes, the changed report will be a concrete confirmation that the configuration was read.
Keep version strings and timestamps out of strict expectations unless they are the thing being tested. A route test should care about the handler or response, not the second at which Spark printed its banner. Similarly, generated migration filenames contain timestamps that differ between learners.
Common mistakes
Typing a command from the wrong directory produces misleading troubleshooting. Using a generator as proof of a complete feature skips the implementation. Adding force to every command risks overwriting work. Finally, mixing inspection and destructive database commands in one copied block makes it hard to stop at the right point. Run each state-changing command because you understand the specific change it makes.
Exercise
Read the help for make:controller, create Probe and lint it. Then inspect routes and explain why a generated class need not appear there. Describe one check that linting cannot perform.
Show an answer
The generator creates a PHP file; it does not add the explicit route this course uses. With auto routing disabled, the class is not exposed just by existing. Linting checks PHP syntax, while an HTTP test checks request behavior. A syntactically valid method can still query the wrong table or return an inappropriate status.
Previous lesson · Next lesson · Related: explicit routes · Related: security boundaries
Key points
- Run Spark from the isolated application root.
- Generated code needs implementation and behavior checks.
- Route reports and PHP lint answer different questions.