Skip to content

Getting Started

v1.0

This guide takes you from zero to a working module in under 5 minutes using the built-in scaffold command.


Prerequisites

  • ChargePanda installed and running
  • PHP 8.1+
  • Composer (no extra packages required — the module system ships with ChargePanda)

1. Scaffold your module

Run the artisan command with your module name in StudlyCase:

bash
php artisan module:make MyPlugin

This creates the following structure under modules/MyPlugin/:

modules/MyPlugin/
├── module.json
├── ModuleServiceProvider.php
├── Http/
│   └── Controllers/
├── Models/
├── database/
│   ├── migrations/
│   └── seeders/
├── resources/
│   └── views/
└── routes/
    ├── web.php
    └── api.php

2. Review module.json

Open modules/MyPlugin/module.json. It was pre-filled by the scaffold:

json
{
    "name": "My Plugin",
    "slug": "my-plugin",
    "version": "1.0.0",
    "description": "",
    "author": "",
    "requires": {
        "chargepanda": ">=1.0.0"
    },
    "enabled": true
}

The slug is used as the view namespace, config key, and URL prefix by convention. Keep it lowercase and hyphenated.


3. Install the module

Register your module in the database so ChargePanda boots it on every request:

bash
php artisan module:install MyPlugin

This inserts a row into the modules table with status active. From this point on, your ModuleServiceProvider is booted automatically.

Tip: You can also install modules through the admin UI at Admin → Modules by uploading a ZIP of the module folder.


4. Verify it loaded

bash
php artisan module:list

You should see MyPlugin listed as active.


5. Add your first route

Open modules/MyPlugin/routes/web.php and add:

php
Route::get('/hello', function () {
    return 'Hello from MyPlugin!';
})->name('my-plugin.hello');

Then tell your service provider to load web routes. Open modules/MyPlugin/ModuleServiceProvider.php:

php
public function boot(): void
{
    $this->loadWebRoutes();
    $this->loadViews();
}

Visit /hello in your browser. You should see "Hello from MyPlugin!".


6. Enable / disable without deleting

In the admin UI (Admin → Modules) you can deactivate a module without uninstalling it. A deactivated module's service provider is not booted, so its routes, migrations, and listeners are all offline.

Click Activate or Deactivate next to the module. The change takes effect on the next page request — no server restart needed.

To check current status from the command line:

bash
php artisan module:list

7. Reinstall a module

If you accidentally deleted a module's product or plans — or need to re-run its setup seeder — use the Reinstall button in Admin → Modules.

Reinstall clears the module's setup_complete flag and re-fires the ModuleActivated event, causing the setup seeder to run again. Seeders use firstOrCreate, so only missing records are created — existing data is not overwritten.


Next steps

Released under the Commercial License.