π€ Dumper in Squehub
The Dumper system in Squehub helps you populate your database with test or fake data using clean PHP logic. It is useful for development, staging, demos, or local testing environments.
π Directory Structure
All Dumper classes must be created inside the database/dumper/ directory.
Each Dumper must extend the base class App\Core\Dumper.
database/
βββ dumper/
βββ UsersDumper.phpπ§© Example Dumper File
This example generates 10 users using the User model.
<?php
namespace Database\Dumper;
use App\Core\Dumper; // β
Always required
use Project\Models\User; // β
Only needed if interacting with the User model
class UsersDumper extends Dumper
{
public function run()
{
for ($i = 1; $i <= 10; $i++) {
User::create([
'name' => "User $i",
'username' => "user$i",
'email' => "user$i@example.com",
'password' => password_hash("password", PASSWORD_DEFAULT),
'country' => 'USA',
'status' => 'active',
]);
}
}
}π Running a Dumper
To run your Dumper class from the CLI:
$ php squehub dump:run UsersDumperThis will call the run() method and insert the data.
β‘ Generate One Automatically
You can use the CLI to scaffold a new Dumper file:
$ php squehub make:Dumper UsersDumperThis creates a file under database/dumper/ with the correct structure.
π Important Notes
- β
Always include
use App\Core\Dumper;at the top β it powers the Dumper system. - β
Only include
use Project\Models\XYZ;when the dumper interacts with that model (e.g.User). - π§ All Dumper classes must have a valid
namespaceβ e.g.namespace Database\Dumper;. - π§ͺ Dumper files are for inserting fake/test data into real database tables.
- π Keep logic simple: create one dumper per dataset type (users, products, orders, etc).
β Summary
- π Dumper files live in
database/dumper/. - π§± They must extend
App\Core\Dumper. - π¦ Use model classes like
use Project\Models\User;only when needed. - π The
run()method contains the data-insertion logic. - π» Run with:
php squehub dump:run YourDumperName.
database/dumper/. Just
ensure the namespace reflects the folder structure.

