Skip to content

πŸš€ Step-by-Step Payment Gateway Module Tutorial ​

This comprehensive tutorial walks you through creating a complete payment gateway module from scratch. We'll build a functional payment gateway module step-by-step, demonstrating every command, file, and configuration needed.


Tutorial Overview ​

In this tutorial, we'll create a TapGateway payment module that demonstrates:

  • Complete module structure creation
  • Essential Artisan commands for module development
  • Step-by-step file generation and configuration
  • Cache management and module activation
  • Testing and verification procedures

πŸ“‹ TUTORIAL APPROACH

This tutorial follows a command-by-command approach where every step is explained in detail with expected outputs and troubleshooting tips.


Prerequisites Check ​

Before starting, ensure you have:

  • Laravel 12.19.3+ installed and configured
  • PHP 8.3+ with required extensions
  • Database connection properly configured
  • Module system installed and working
  • Command line access to your Laravel application
  • Proper file permissions for module creation

Verify Environment ​

bash
# Check PHP version
php --version
# Expected: PHP 8.3.x or higher

# Check Laravel version
php artisan --version
# Expected: Laravel Framework 12.19.3 or higher

# Check if module system is available
php artisan module:list
# Should display module commands and current modules

Step 1: Create the Module Structure ​

1.1 Generate Base Module ​

Command: Use the Laravel module command with the critical --type=custom flag:

bash
php artisan module:make TapGateway --type=custom

⚠️ CRITICAL COMMAND

Always use php artisan module:make ModuleName --type=custom when creating payment gateway modules. The --type=custom flag is essential for proper module structure and configuration.

Expected Output:

text
[TapGateway] module created successfully.
Module type: Custom
To activate the module, run: php artisan module:activate TapGateway

What This Command Does:

  1. Creates the complete directory structure under Modules/TapGateway/
  2. Generates essential configuration files (module.json, composer.json, package.json)
  3. Creates basic service providers and route providers
  4. Sets up asset compilation configuration (vite.config.js)
  5. Creates initial directory structure for controllers, views, routes
  6. Establishes proper PHP namespacing and autoloading

1.2 Verify Module Creation ​

Check Module Directory:

bash
# Navigate to the module directory
cd Modules/TapGateway

# List all generated files and directories
ls -la

Expected Directory Structure:

text
total XX
drwxr-xr-x  XX user user XXXX MMM DD HH:MM .
drwxr-xr-x  XX user user XXXX MMM DD HH:MM ..
-rw-r--r--   1 user user  XXX MMM DD HH:MM composer.json
-rw-r--r--   1 user user  XXX MMM DD HH:MM module.json
-rw-r--r--   1 user user  XXX MMM DD HH:MM package.json
-rw-r--r--   1 user user  XXX MMM DD HH:MM README.md
-rw-r--r--   1 user user  XXX MMM DD HH:MM TapGateway.php
-rw-r--r--   1 user user  XXX MMM DD HH:MM vite.config.js
drwxr-xr-x   X user user  XXX MMM DD HH:MM Config/
drwxr-xr-x   X user user  XXX MMM DD HH:MM Console/
drwxr-xr-x   X user user  XXX MMM DD HH:MM Database/
drwxr-xr-x   X user user  XXX MMM DD HH:MM Http/
drwxr-xr-x   X user user  XXX MMM DD HH:MM Livewire/
drwxr-xr-x   X user user  XXX MMM DD HH:MM Models/
drwxr-xr-x   X user user  XXX MMM DD HH:MM Providers/
drwxr-xr-x   X user user  XXX MMM DD HH:MM resources/
drwxr-xr-x   X user user  XXX MMM DD HH:MM Routes/

1.3 Examine Generated Configuration ​

Check module.json Configuration:

bash
cat module.json

Expected Content:

json
{
    "name": "TapGateway",
    "alias": "tap-gateway",
    "namespace": "Modules\\TapGateway\\",
    "provider": "Modules\\TapGateway\\Providers\\TapGatewayServiceProvider",
    "author": "Corbital Technologies",
    "url": "https://codecanyon.net/user/corbitaltech",
    "version": "1.0.0",
    "description": "The TapGateway Module",
    "keywords": [],
    "order": 0,
    "providers": [
        "Modules\\TapGateway\\Providers\\TapGatewayServiceProvider"
    ],
    "aliases": [],
    "require": [],
    "conflicts": [],
    "type": "custom"
}

Configuration Explanation:

  • name: Module identifier for commands and references
  • alias: URL-friendly name for routing
  • namespace: PHP namespace for all module classes
  • provider: Main service provider class
  • type: custom indicates this is a custom module (not core system)

Step 2: Generate Core Module Components ​

2.1 Create Admin Controllers ​

Generate Admin Settings Controller:

bash
php artisan module:make-controller Admin/TapGatewaySettingsController TapGateway

Expected Output:

text
Controller [Admin/TapGatewaySettingsController] created successfully.

Generated File Location: Modules/TapGateway/Http/Controllers/Admin/TapGatewaySettingsController.php

Verify Controller Creation:

bash
ls -la Http/Controllers/Admin/

Expected Output:

text
total XX
drwxr-xr-x X user user XXX MMM DD HH:MM .
drwxr-xr-x X user user XXX MMM DD HH:MM ..
-rw-r--r-- 1 user user XXX MMM DD HH:MM TapGatewaySettingsController.php

2.2 Create Payment Gateway Controller ​

Generate Payment Gateway Controller:

bash
php artisan module:make-controller PaymentGateways/TapGatewayController TapGateway

Expected Output:

text
Controller [PaymentGateways/TapGatewayController] created successfully.

Generated File Location: Modules/TapGateway/Http/Controllers/PaymentGateways/TapGatewayController.php

2.3 Create API Controller ​

Generate API Controller:

bash
php artisan module:make-controller Api/TapGatewayApiController TapGateway

Expected Output:

text
Controller [Api/TapGatewayApiController] created successfully.

2.4 Verify All Controllers ​

Check Complete Controller Structure:

bash
find Http/Controllers -name "*.php" -type f

Expected Output:

text
Http/Controllers/TapGatewayController.php
Http/Controllers/Admin/TapGatewaySettingsController.php
Http/Controllers/Api/TapGatewayApiController.php
Http/Controllers/PaymentGateways/TapGatewayController.php

Step 3: Create Service Classes ​

3.1 Create Main Payment Gateway Service ​

Generate Payment Gateway Service:

bash
php artisan module:make-class Services/TapGatewayPaymentGateway TapGateway

Expected Output:

text
Class [Services/TapGatewayPaymentGateway] created successfully.

Generated File Location: Modules/TapGateway/Services/TapGatewayPaymentGateway.php

3.2 Create API Service ​

Generate API Service:

bash
php artisan module:make-class Services/TapGatewayService TapGateway

Expected Output:

text
Class [Services/TapGatewayService] created successfully.

3.3 Create Helper Services ​

Generate Webhook Service:

bash
php artisan module:make-class Services/TapGatewayWebhookService TapGateway

Generate Validation Service:

bash
php artisan module:make-class Services/TapGatewayValidationService TapGateway

3.4 Verify Services Directory ​

Check Services Structure:

bash
ls -la Services/

Expected Output:

text
total XX
drwxr-xr-x X user user XXX MMM DD HH:MM .
drwxr-xr-x X user user XXX MMM DD HH:MM ..
-rw-r--r-- 1 user user XXX MMM DD HH:MM TapGatewayPaymentGateway.php
-rw-r--r-- 1 user user XXX MMM DD HH:MM TapGatewayService.php
-rw-r--r-- 1 user user XXX MMM DD HH:MM TapGatewayValidationService.php
-rw-r--r-- 1 user user XXX MMM DD HH:MM TapGatewayWebhookService.php

Step 4: Create Event Listeners ​

4.1 Generate Gateway Registration Listener ​

Create Gateway Registration Listener:

bash
php artisan module:make-listener RegisterTapGateway TapGateway

Expected Output:

text
Listener [RegisterTapGateway] created successfully.

Generated File Location: Modules/TapGateway/Listeners/RegisterTapGateway.php

4.2 Generate Settings Extension Listener ​

Create Settings Extension Listener:

bash
php artisan module:make-listener ExtendPaymentSettings TapGateway

Expected Output:

text
Listener [ExtendPaymentSettings] created successfully.

4.3 Generate Admin Panel Listener ​

Create Admin Panel Listener:

bash
php artisan module:make-listener AddTapGatewayPaymentSettings TapGateway

Expected Output:

text
Listener [AddTapGatewayPaymentSettings] created successfully.

4.4 Verify Listeners Directory ​

Check Listeners Structure:

bash
ls -la Listeners/

Expected Output:

text
total XX
drwxr-xr-x X user user XXX MMM DD HH:MM .
drwxr-xr-x X user user XXX MMM DD HH:MM ..
-rw-r--r-- 1 user user XXX MMM DD HH:MM AddTapGatewayPaymentSettings.php
-rw-r--r-- 1 user user XXX MMM DD HH:MM ExtendPaymentSettings.php
-rw-r--r-- 1 user user XXX MMM DD HH:MM RegisterTapGateway.php

Step 5: Create Models and Database Components ​

5.1 Create Transaction Model ​

Generate Transaction Model with Migration:

bash
php artisan module:make-model TapGatewayTransaction TapGateway -m

Expected Output:

text
Model [TapGatewayTransaction] created successfully.
Migration [create_tap_gateway_transactions_table] created successfully.

Generated Files:

  • Modules/TapGateway/Models/TapGatewayTransaction.php
  • Modules/TapGateway/Database/Migrations/YYYY_MM_DD_HHMMSS_create_tap_gateway_transactions_table.php

5.2 Create Additional Models ​

Generate Refund Model with Migration and Factory:

bash
php artisan module:make-model TapGatewayRefund TapGateway -mf

Generate Webhook Log Model with Migration, Factory, and Seeder:

bash
php artisan module:make-model TapGatewayWebhookLog TapGateway -mfs

5.3 Create Settings Migration ​

Generate Settings Migration:

bash
php artisan module:make-migration add_tap_gateway_payment_settings TapGateway

Expected Output:

text
Migration [add_tap_gateway_payment_settings] created successfully.

5.4 Verify Database Components ​

Check Models Directory:

bash
ls -la Models/

Check Migrations Directory:

bash
ls -la Database/Migrations/

Check Factories Directory:

bash
ls -la Database/Factories/

Check Seeders Directory:

bash
ls -la Database/Seeders/

Step 6: Create Request Validation Classes ​

6.1 Create Payment Request ​

Generate Payment Request Validation:

bash
php artisan module:make-request TapGatewayPaymentRequest TapGateway

Expected Output:

text
Request [TapGatewayPaymentRequest] created successfully.

6.2 Create Admin Settings Request ​

Generate Admin Settings Request:

bash
php artisan module:make-request Admin/TapGatewaySettingsRequest TapGateway

Expected Output:

text
Request [Admin/TapGatewaySettingsRequest] created successfully.

6.3 Verify Requests Directory ​

Check Requests Structure:

bash
find Http/Requests -name "*.php" -type f

Expected Output:

text
Http/Requests/Admin/TapGatewaySettingsRequest.php
Http/Requests/TapGatewayPaymentRequest.php

Step 7: Create Middleware ​

7.1 Create Payment Verification Middleware ​

Generate Payment Verification Middleware:

bash
php artisan module:make-middleware TapGatewayVerifyPayment TapGateway

Expected Output:

text
Middleware [TapGatewayVerifyPayment] created successfully.

7.2 Create Webhook Signature Middleware ​

Generate Webhook Signature Middleware:

bash
php artisan module:make-middleware TapGatewayVerifyWebhook TapGateway

Expected Output:

text
Middleware [TapGatewayVerifyWebhook] created successfully.

7.3 Verify Middleware Directory ​

Check Middleware Structure:

bash
ls -la Http/Middleware/

Expected Output:

text
total XX
drwxr-xr-x X user user XXX MMM DD HH:MM .
drwxr-xr-x X user user XXX MMM DD HH:MM ..
-rw-r--r-- 1 user user XXX MMM DD HH:MM TapGatewayVerifyPayment.php
-rw-r--r-- 1 user user XXX MMM DD HH:MM TapGatewayVerifyWebhook.php

Step 8: Create Jobs and Queued Tasks ​

8.1 Create Payment Processing Job ​

Generate Payment Processing Job:

bash
php artisan module:make-job ProcessTapGatewayPayment TapGateway

Expected Output:

text
Job [ProcessTapGatewayPayment] created successfully.

8.2 Create Webhook Processing Job ​

Generate Webhook Processing Job:

bash
php artisan module:make-job ProcessTapGatewayWebhook TapGateway

Expected Output:

text
Job [ProcessTapGatewayWebhook] created successfully.

8.3 Create Notification Job ​

Generate Notification Job:

bash
php artisan module:make-job SendTapGatewayNotification TapGateway

Expected Output:

text
Job [SendTapGatewayNotification] created successfully.

8.4 Verify Jobs Directory ​

Check Jobs Structure:

bash
ls -la Jobs/

Expected Output:

text
total XX
drwxr-xr-x X user user XXX MMM DD HH:MM .
drwxr-xr-x X user user XXX MMM DD HH:MM ..
-rw-r--r-- 1 user user XXX MMM DD HH:MM ProcessTapGatewayPayment.php
-rw-r--r-- 1 user user XXX MMM DD HH:MM ProcessTapGatewayWebhook.php
-rw-r--r-- 1 user user XXX MMM DD HH:MM SendTapGatewayNotification.php

Step 9: Create Event Classes ​

9.1 Create Payment Events ​

Generate Payment Started Event:

bash
php artisan module:make-event TapGatewayPaymentStarted TapGateway

Generate Payment Completed Event:

bash
php artisan module:make-event TapGatewayPaymentCompleted TapGateway

Generate Payment Failed Event:

bash
php artisan module:make-event TapGatewayPaymentFailed TapGateway

9.2 Create Webhook Event ​

Generate Webhook Received Event:

bash
php artisan module:make-event TapGatewayWebhookReceived TapGateway

9.3 Verify Events Directory ​

Check Events Structure:

bash
ls -la Events/

Expected Output:

text
total XX
drwxr-xr-x X user user XXX MMM DD HH:MM .
drwxr-xr-x X user user XXX MMM DD HH:MM ..
-rw-r--r-- 1 user user XXX MMM DD HH:MM TapGatewayPaymentCompleted.php
-rw-r--r-- 1 user user XXX MMM DD HH:MM TapGatewayPaymentFailed.php
-rw-r--r-- 1 user user XXX MMM DD HH:MM TapGatewayPaymentStarted.php
-rw-r--r-- 1 user user XXX MMM DD HH:MM TapGatewayWebhookReceived.php

Step 10: Create API Resources ​

10.1 Create Payment Resource ​

Generate Payment Resource:

bash
php artisan module:make-resource TapGatewayPaymentResource TapGateway

Expected Output:

text
Resource [TapGatewayPaymentResource] created successfully.

10.2 Create Transaction Collection ​

Generate Transaction Collection:

bash
php artisan module:make-resource TapGatewayTransactionCollection TapGateway

Expected Output:

text
Resource [TapGatewayTransactionCollection] created successfully.

10.3 Verify Resources Directory ​

Check Resources Structure:

bash
ls -la Http/Resources/

Expected Output:

text
total XX
drwxr-xr-x X user user XXX MMM DD HH:MM .
drwxr-xr-x X user user XXX MMM DD HH:MM ..
-rw-r--r-- 1 user user XXX MMM DD HH:MM TapGatewayPaymentResource.php
-rw-r--r-- 1 user user XXX MMM DD HH:MM TapGatewayTransactionCollection.php

Step 11: Create Tests ​

11.1 Create Feature Tests ​

Generate Payment Feature Test:

bash
php artisan module:make-test TapGatewayPaymentTest TapGateway

Generate Admin Settings Feature Test:

bash
php artisan module:make-test Admin/TapGatewaySettingsTest TapGateway

11.2 Create Unit Tests ​

Generate Service Unit Test:

bash
php artisan module:make-test Services/TapGatewayServiceTest TapGateway --unit

Generate Model Unit Test:

bash
php artisan module:make-test Models/TapGatewayTransactionTest TapGateway --unit

11.3 Verify Tests Directory ​

Check Tests Structure:

bash
find Tests -name "*.php" -type f

Expected Output:

text
Tests/Feature/Admin/TapGatewaySettingsTest.php
Tests/Feature/TapGatewayPaymentTest.php
Tests/Unit/Models/TapGatewayTransactionTest.php
Tests/Unit/Services/TapGatewayServiceTest.php

Step 12: Create Additional Components ​

12.1 Create Mail Classes ​

Generate Payment Confirmation Mail:

bash
php artisan module:make-mail TapGatewayPaymentConfirmation TapGateway

Generate Payment Failed Mail:

bash
php artisan module:make-mail TapGatewayPaymentFailed TapGateway

12.2 Create Notifications ​

Generate Payment Notification:

bash
php artisan module:make-notification TapGatewayPaymentNotification TapGateway

12.3 Create Custom Commands ​

Generate Sync Command:

bash
php artisan module:make-command SyncTapGatewayPayments TapGateway

Generate Health Check Command:

bash
php artisan module:make-command TapGatewayHealthCheck TapGateway

12.4 Create Seeders ​

Generate Settings Seeder:

bash
php artisan module:make-seeder TapGatewaySettingsSeeder TapGateway

Generate Main Database Seeder:

bash
php artisan module:make-seeder TapGatewayDatabaseSeeder TapGateway

Step 13: Verify Complete Module Structure ​

13.1 Check Complete Directory Tree ​

Generate Complete Directory Tree:

bash
cd Modules/TapGateway
tree

Expected Complete Structure:

text
.
β”œβ”€β”€ composer.json
β”œβ”€β”€ module.json
β”œβ”€β”€ package.json
β”œβ”€β”€ README.md
β”œβ”€β”€ TapGateway.php
β”œβ”€β”€ vite.config.js
β”œβ”€β”€ Config/
β”‚   └── config.php
β”œβ”€β”€ Console/
β”‚   β”œβ”€β”€ SyncTapGatewayPayments.php
β”‚   └── TapGatewayHealthCheck.php
β”œβ”€β”€ Database/
β”‚   β”œβ”€β”€ Factories/
β”‚   β”‚   β”œβ”€β”€ TapGatewayRefundFactory.php
β”‚   β”‚   └── TapGatewayWebhookLogFactory.php
β”‚   β”œβ”€β”€ Migrations/
β”‚   β”‚   β”œβ”€β”€ [timestamp]_create_tap_gateway_transactions_table.php
β”‚   β”‚   β”œβ”€β”€ [timestamp]_create_tap_gateway_refunds_table.php
β”‚   β”‚   β”œβ”€β”€ [timestamp]_create_tap_gateway_webhook_logs_table.php
β”‚   β”‚   └── [timestamp]_add_tap_gateway_payment_settings.php
β”‚   └── Seeders/
β”‚       β”œβ”€β”€ TapGatewayDatabaseSeeder.php
β”‚       β”œβ”€β”€ TapGatewaySettingsSeeder.php
β”‚       └── TapGatewayWebhookLogSeeder.php
β”œβ”€β”€ Events/
β”‚   β”œβ”€β”€ TapGatewayPaymentCompleted.php
β”‚   β”œβ”€β”€ TapGatewayPaymentFailed.php
β”‚   β”œβ”€β”€ TapGatewayPaymentStarted.php
β”‚   └── TapGatewayWebhookReceived.php
β”œβ”€β”€ Http/
β”‚   β”œβ”€β”€ Controllers/
β”‚   β”‚   β”œβ”€β”€ TapGatewayController.php
β”‚   β”‚   β”œβ”€β”€ Admin/
β”‚   β”‚   β”‚   └── TapGatewaySettingsController.php
β”‚   β”‚   β”œβ”€β”€ Api/
β”‚   β”‚   β”‚   └── TapGatewayApiController.php
β”‚   β”‚   └── PaymentGateways/
β”‚   β”‚       └── TapGatewayController.php
β”‚   β”œβ”€β”€ Middleware/
β”‚   β”‚   β”œβ”€β”€ TapGatewayVerifyPayment.php
β”‚   β”‚   └── TapGatewayVerifyWebhook.php
β”‚   β”œβ”€β”€ Requests/
β”‚   β”‚   β”œβ”€β”€ TapGatewayPaymentRequest.php
β”‚   β”‚   └── Admin/
β”‚   β”‚       └── TapGatewaySettingsRequest.php
β”‚   └── Resources/
β”‚       β”œβ”€β”€ TapGatewayPaymentResource.php
β”‚       └── TapGatewayTransactionCollection.php
β”œβ”€β”€ Jobs/
β”‚   β”œβ”€β”€ ProcessTapGatewayPayment.php
β”‚   β”œβ”€β”€ ProcessTapGatewayWebhook.php
β”‚   └── SendTapGatewayNotification.php
β”œβ”€β”€ Listeners/
β”‚   β”œβ”€β”€ AddTapGatewayPaymentSettings.php
β”‚   β”œβ”€β”€ ExtendPaymentSettings.php
β”‚   └── RegisterTapGateway.php
β”œβ”€β”€ Livewire/
β”œβ”€β”€ Mail/
β”‚   β”œβ”€β”€ TapGatewayPaymentConfirmation.php
β”‚   └── TapGatewayPaymentFailed.php
β”œβ”€β”€ Models/
β”‚   β”œβ”€β”€ TapGatewayRefund.php
β”‚   β”œβ”€β”€ TapGatewayTransaction.php
β”‚   └── TapGatewayWebhookLog.php
β”œβ”€β”€ Notifications/
β”‚   └── TapGatewayPaymentNotification.php
β”œβ”€β”€ Providers/
β”‚   β”œβ”€β”€ RouteServiceProvider.php
β”‚   └── TapGatewayServiceProvider.php
β”œβ”€β”€ resources/
β”‚   β”œβ”€β”€ assets/
β”‚   β”‚   β”œβ”€β”€ css/
β”‚   β”‚   β”‚   └── app.css
β”‚   β”‚   └── js/
β”‚   β”‚       └── app.js
β”‚   β”œβ”€β”€ lang/
β”‚   β”‚   β”œβ”€β”€ en.json
β”‚   β”‚   └── tenant_en.json
β”‚   └── views/
β”‚       └── index.blade.php
β”œβ”€β”€ Routes/
β”‚   β”œβ”€β”€ api.php
β”‚   └── web.php
β”œβ”€β”€ Services/
β”‚   β”œβ”€β”€ TapGatewayPaymentGateway.php
β”‚   β”œβ”€β”€ TapGatewayService.php
β”‚   β”œβ”€β”€ TapGatewayValidationService.php
β”‚   └── TapGatewayWebhookService.php
└── Tests/
    β”œβ”€β”€ Feature/
    β”‚   β”œβ”€β”€ TapGatewayPaymentTest.php
    β”‚   └── Admin/
    β”‚       └── TapGatewaySettingsTest.php
    └── Unit/
        β”œβ”€β”€ Models/
        β”‚   └── TapGatewayTransactionTest.php
        └── Services/
            └── TapGatewayServiceTest.php

13.2 Count Generated Files ​

Count All Generated Files:

bash
find . -name "*.php" -type f | wc -l

Expected Count: Approximately 40-50 PHP files (depending on additional components created)


Step 14: Module Activation and Management ​

14.1 Check Module Status ​

List All Modules:

bash
cd ../../  # Return to Laravel root directory
php artisan module:list

Expected Output:

text
+-------------+---------+----------+----------+---------+
| Name        | Status  | Order    | Path     | Version |
+-------------+---------+----------+----------+---------+
| TapGateway  | Disabled| 0        | Modules/ | 1.0.0   |
+-------------+---------+----------+----------+---------+

14.2 Enable the Module ​

Enable TapGateway Module:

bash
php artisan module:enable TapGateway

Expected Output:

text
Module [TapGateway] enabled successfully.

14.3 Verify Module Status ​

Check Module Status Again:

bash
php artisan module:list

Expected Output:

text
+-------------+---------+----------+----------+---------+
| Name        | Status  | Order    | Path     | Version |
+-------------+---------+----------+----------+---------+
| TapGateway  | Enabled | 0        | Modules/ | 1.0.0   |
+-------------+---------+----------+----------+---------+

14.4 Show Module Details ​

Display Module Information:

bash
php artisan module:show TapGateway

Expected Output:

text
****************************************
Name        : TapGateway
Alias       : tap-gateway
Status      : Enabled
Order       : 0
Path        : Modules/TapGateway
Namespace   : Modules\TapGateway\
Provider    : Modules\TapGateway\Providers\TapGatewayServiceProvider
****************************************

Step 15: Cache Management and Optimization ​

15.1 Clear All Caches ​

After module creation and activation, clear all application caches:

Clear Application Cache:

bash
php artisan cache:clear

Expected Output:

text
Application cache cleared!

Clear Configuration Cache:

bash
php artisan config:clear

Expected Output:

text
Configuration cache cleared!

Clear Route Cache:

bash
php artisan route:clear

Expected Output:

text
Route cache cleared!

Clear View Cache:

bash
php artisan view:clear

Expected Output:

text
Compiled views cleared!

15.2 Restart Queue Workers (if applicable) ​

Restart Queue Workers:

bash
php artisan queue:restart

Expected Output:

text
Broadcasting queue restart signal.

15.3 Dump Composer Autoload ​

Regenerate Composer Autoload:

bash
composer dump-autoload

Expected Output:

text
Generating optimized autoload files
Generated optimized autoload files containing X classes

Step 16: Run Database Migrations (Optional) ​

16.1 Run Module Migrations ​

If you created migrations, run them:

Run All Migrations:

bash
php artisan migrate

Run Only Module Migrations:

bash
php artisan module:migrate TapGateway

16.2 Run Module Seeders (Optional) ​

Run Module Seeders:

bash
php artisan module:seed TapGateway

Step 17: Testing and Verification ​

17.1 Test Route Registration ​

Check Route List:

bash
php artisan route:list | grep -i tap

Expected: Should show any routes defined in the module's route files.

17.2 Test Module Autoloading ​

Test Namespace Autoloading:

bash
php artisan tinker
php
// In Tinker console
use Modules\TapGateway\Services\TapGatewayService;
$service = new TapGatewayService();
exit;

Expected: No errors if autoloading is working correctly.

17.3 Run Module Tests (if created) ​

Run Module Tests:

bash
php artisan test Modules/TapGateway/Tests/

Step 18: Development Best Practices ​

18.1 Module Development Workflow ​

Recommended Development Cycle:

  1. Generate Components: Use Artisan commands to create new components
  2. Clear Caches: Clear caches after structural changes
  3. Test Changes: Test functionality after each major change
  4. Commit Changes: Use version control for all changes
  5. Document Changes: Update module documentation

18.2 Common Commands Reference ​

Essential Module Commands:

bash
# Module Status
php artisan module:list
php artisan module:show ModuleName

# Module Management
php artisan module:enable ModuleName
php artisan module:disable ModuleName

# Component Generation
php artisan module:make-controller ControllerName ModuleName
php artisan module:make-model ModelName ModuleName -m
php artisan module:make-service ServiceName ModuleName

# Database Operations
php artisan module:migrate ModuleName
php artisan module:seed ModuleName

# Cache Management
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear

Troubleshooting Common Issues ​

Issue 1: Module Not Appearing in List ​

Problem: Module doesn't appear when running php artisan module:list

Solutions:

  1. Check module.json exists and is valid JSON
  2. Verify module is in correct directory structure
  3. Run composer dump-autoload
  4. Clear configuration cache: php artisan config:clear

Issue 2: Autoloading Problems ​

Problem: Classes not found when trying to use module components

Solutions:

  1. Check composer.json autoload section
  2. Verify namespace matches directory structure
  3. Run composer dump-autoload
  4. Check file and directory permissions

Issue 3: Routes Not Working ​

Problem: Module routes not accessible

Solutions:

  1. Verify routes are defined in Routes/web.php or Routes/api.php
  2. Check route service provider is registered
  3. Clear route cache: php artisan route:clear
  4. Ensure module is enabled

Issue 4: Views Not Found ​

Problem: Blade views not found or not rendering

Solutions:

  1. Check views are in correct directory: resources/views/
  2. Verify view namespace registration in service provider
  3. Clear view cache: php artisan view:clear
  4. Check view file names and extensions

Next Steps ​

After completing this tutorial, you should have:

βœ… Complete Module Structure: Fully generated payment gateway module
βœ… All Core Components: Controllers, services, models, and more
βœ… Proper Configuration: Module properly configured and activated
βœ… Working Environment: Caches cleared and autoloading functional

Continue Your Learning ​

  1. Payment Gateway Guide - Implement actual payment processing logic
  2. Module Structure Guide - Deep dive into module architecture
  3. Advanced Topics - Advanced patterns and best practices

Implementation Checklist ​

  • [ ] Implement payment gateway interface
  • [ ] Configure payment settings
  • [ ] Create admin configuration pages
  • [ ] Implement webhook handlers
  • [ ] Add proper error handling
  • [ ] Create comprehensive tests
  • [ ] Add logging and monitoring
  • [ ] Document API endpoints

πŸ’‘ IMPORTANT REMINDER

This tutorial showed you how to generate the complete module structure. The next step is implementing the actual payment gateway functionality using the Payment Gateway Guide.


Congratulations! πŸŽ‰ You've successfully created a complete payment gateway module structure. The module is now ready for payment gateway implementation and customization.

Need help? Check our FAQ section or join the Developer Community.

Β© 2024 - Corbital Technologies. All rights reserved.