PHP code example of resumex / sdk

1. Go to this page and download the library: Download resumex/sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

resumex / sdk example snippets


use ResumeX\Facades\ResumeX;

// Generate a CV (Standard templates: classic, basic, two-column-modern)
$cv = ResumeX::cv()->generate([
    'userId' => 'user_123',
    'templateId' => 'classic',
    'email' => '[email protected]',
    'firstName' => 'NGUYEN VAN',
    'lastName' => 'A',
    'phoneNumber' => '0123-456-789',
    'location' => 'Japan',
    'linkedinUrl' => 'https://linkedin.com/in/username',
    'githubUrl' => 'https://github.com/username',
    'professionalSummary' => 'Senior Software Engineer with 5+ years experience...',
    'workExperience' => [
        [
            'company' => 'ABC Tech Company',
            'position' => 'Senior Software Engineer',
            'location' => 'Tokyo',
            'startDate' => '01/2020',
            'endDate' => null,
            'isPresent' => true,
            'description' => ['Led development of microservices architecture...'],
            'technologies' => ['PHP', 'Laravel', 'React'],
        ],
    ],
    'education' => [
        [
            'school' => 'University of Technology',
            'degree' => 'Bachelor of Computer Science',
            'location' => 'Ho Chi Minh',
            'startDate' => '2013-09',
            'endDate' => '2017-06',
            'isPresent' => false,
        ],
    ],
    'skills' => [
        ['category' => 'Backend', 'items' => ['PHP', 'Laravel', 'Node.js']],
        ['category' => 'Frontend', 'items' => ['React', 'Vue.js', 'TypeScript']],
    ],
    // Optional: Projects
    'projects' => [
        [
            'name' => 'E-commerce Platform',
            'description' => ['Built scalable microservices architecture', 'Handled 10k+ daily transactions'],
            'startDate' => '01/2024',
            'endDate' => '12/2024',
            'isPresent' => false,
            'technologies' => ['Laravel', 'React', 'AWS', 'Docker'],
            'url' => 'https://project-demo.com',
        ],
    ],
    // Optional: Additional Information (Certifications, Awards, Publications, etc.)
    'additionalInformation' => [
        [
            'title' => 'Certifications',
            'items' => [
                [
                    'name' => 'AWS Certified Solutions Architect',
                    'organization' => 'Amazon Web Services',
                    'startDate' => '03/2024',
                    'endDate' => null,
                    'isPresent' => false,
                    'description' => 'Professional level certification',
                ],
                [
                    'name' => 'Laravel Certified Developer',
                    'organization' => 'Laravel',
                    'startDate' => '06/2023',
                    'endDate' => null,
                    'isPresent' => false,
                ],
            ],
        ],
        [
            'title' => 'Publications',
            'items' => [
                [
                    'name' => 'Building Scalable APIs with Laravel',
                    'organization' => 'Medium',
                    'startDate' => '11/2023',
                    'endDate' => null,
                    'isPresent' => false,
                    'description' => 'Technical article with 5k+ views',
                ],
            ],
        ],
    ],
    'preferences' => [
        'language' => 'en',
    ],
]);

// Get the editor URL
$editorUrl = $cv['editorUrl'];

// Redirect user or embed in iframe
return redirect($editorUrl);

use ResumeX\Facades\ResumeX;

$cv = ResumeX::cv()->generate([
    // ============================================
    // Required fields (top-level)
    // ============================================
    'userId' => 'user_123',
    'templateId' => 'professional-grid',
    'email' => '[email protected]',

    // ============================================
    // Basic Info (top-level for Japanese CV)
    // ============================================
    'firstName' => '太郎',
    'lastName' => '山田',
    'firstNameKatana' => 'タロウ',
    'lastNameKatana' => 'ヤマダ',
    'phoneNumber' => '090-1234-5678',
    'postCode' => '100-0001',
    'location' => '東京都千代田区丸の内1-1-1',

    // Birth Date (split into year, month, day)
    'birthYear' => '1990',
    'birthMonth' => '5',
    'birthDay' => '15',
    'gender' => 'male',   // 'male' | 'female' | 'other'

    // Profile Photo
    'profilePhoto' => 'https://example.com/photo.jpg',

    // ============================================
    // Standard CV sections (if you have them)
    // ============================================
    'workExperience' => [
        [
            'company' => '株式会社ABC',
            'position' => 'システムエンジニア',
            'location' => '東京',
            'startDate' => '04/2020',
            'endDate' => null,
            'isPresent' => true,
            'description' => ['Webアプリケーションの設計・開発'],
            'technologies' => ['PHP', 'Laravel', 'React'],
        ],
    ],
    'education' => [
        [
            'school' => '東京大学',
            'degree' => '学士',
            'field' => '情報工学',
            'location' => '東京',
            'startDate' => '2012-04',
            'endDate' => '2016-03',
            'isPresent' => false,
            'gpa' => '',
            'achievements' => [],
        ],
    ],
    'skills' => [],

    // ============================================
    // Japanese CV specific fields (webCv)
    // ============================================
    'webCv' => [
        // Qualifications list (資格一覧)
        'qualificationList' => [
            ['date' => '2018年6月', 'qualification_name' => '普通自動車第一種運転免許'],
            ['date' => '2019年12月', 'qualification_name' => 'TOEIC 850点'],
        ],

        // Detailed work experience for 職務経歴書
        'cv_work_experience' => [
            [
                'company_name' => '株式会社○○',
                'business_description' => 'Webサービス開発',
                'capital' => '1000万円',
                'employee_number' => '50',
                'classification' => '1',  // 1=正社員
                'job_type' => 'エンジニア',
                'job_detail' => 'システム開発・保守',
                'sales' => '5億円',
                'retirement' => '0',  // 0=在職中, 1=退職済み
                'affiliation_period_year' => '2020',
                'affiliation_period_month' => '4',
                'affiliation_period_day' => '1',
                'affiliation_period_end_year' => '',
                'affiliation_period_end_month' => '',
                'affiliation_period_end_day' => '',
            ],
        ],

        // Japanese CV text sections
        'applying_info' => '御社の先進的な技術と企業文化に魅力を感じ...',
        'experience_info' => '私の強みはチームワークとコミュニケーション能力です...',
        'personal_info' => '特になし',
        'cv_job_summary' => 'IT業界で10年以上の経験を持つエンジニア',
        'cv_experience_skill_knowledge' => 'PHP, Laravel, React, AWS',
        'cv_qualifications_held' => '普通自動車免許、TOEIC 850点',
        'cv_self_promotion' => '新しい技術への学習意欲が高く...',

        // Family info
        'spouse' => 1,  // 0=なし, 1=あり
        'spouse_support' => 0,  // 0=なし, 1=あり
        'commuting_time' => '45分',
    ],

    'preferences' => [
        'language' => 'ja',
    ],
]);

// Current position
[
    'company' => 'ABC Corp',
    'position' => 'Senior Engineer',
    'startDate' => '01/2020',
    'endDate' => null,
    'isPresent' => true,
    // ...
}

// Past position
[
    'company' => 'XYZ Inc',
    'position' => 'Engineer',
    'startDate' => '2018-03',
    'endDate' => '2019-12',
    'isPresent' => false,
    // ...
]

// Education (completed)
[
    'school' => 'University of Tokyo',
    'degree' => 'Bachelor of Science',
    'startDate' => '2014-04',
    'endDate' => '2018-03',
    'isPresent' => false,
    // ...
]

// Project (ongoing)
[
    'name' => 'E-commerce Platform',
    'startDate' => '06/2025',
    'endDate' => null,
    'isPresent' => true,
    'description' => ['Building scalable platform...'],
    // ...
]

use ResumeX\Client;

class CVController extends Controller
{
    public function __construct(
        protected Client $resumex
    ) {}

    public function generate(Request $request)
    {
        $cv = $this->resumex->cv()->generate([
            'userId' => (string) $request->user()->id,
            'templateId' => $request->input('templateId', 'classic'),
            'email' => $request->user()->email,
            'firstName' => $request->input('firstName'),
            'lastName' => $request->input('lastName'),
            'workExperience' => $request->input('workExperience', []),
            // ...
        ]);

        return response()->json([
            'cvId' => $cv['cvId'],
            'editorUrl' => $cv['editorUrl'],
        ]);
    }
}

use ResumeX\Client;

$client = new Client([
    'api_key' => 'rx_pub_your_api_key',
    'api_secret' => 'your_api_secret',
    'environment' => 'production', // or 'sandbox'
]);

// Generate CV
$cv = $client->cv()->generate([...]);

// Get CV details
$cvDetails = $client->cv()->get($cv['cvId']);

// Get quota
$quota = $client->partner()->getQuota();

// Generate new CV
$cv = ResumeX::cv()->generate([...]);

// Get CV details
$cv = ResumeX::cv()->get('cv_xyz789');

// Update existing CV (same structure as generate())
$updatedCv = ResumeX::cv()->update('cv_xyz789', [
    'firstName' => 'NGUYEN VAN',
    'lastName' => 'B',
    'phoneNumber' => '0987-654-321',
    'location' => 'Tokyo, Japan',
    'professionalSummary' => 'Updated summary...',
    'workExperience' => [
        [
            'company' => 'New Company',
            'position' => 'Lead Engineer',
            'location' => 'Tokyo',
            'startDate' => '01/2026',
            'endDate' => null,
            'isPresent' => true,
            'description' => ['Leading team of 5...'],
        ],
    ],
    // Or for Japanese CV:
    'webCv' => [
        'lastName' => '山田',
        'firstName' => '太郎',
        'careerHistory' => [
            ['date' => '2015年4月', 'event' => '○○株式会社 入社'],
            ['date' => '2020年3月', 'event' => '○○株式会社 退社'],
        ],
        'selfPr' => '更新された自己PR...',
    ],
]);

// Enhance CV with AI
$enhanced = ResumeX::cv()->enhance('cv_xyz789', [
    'sections' => ['summary', 'experience'],
    'tone' => 'professional',
    'atsOptimization' => true,
]);

// Delete CV
ResumeX::cv()->delete('cv_xyz789');

// Get quota information
$quota = ResumeX::partner()->getQuota();

// Get usage statistics
$usage = ResumeX::partner()->getUsage('current_month');

// Get analytics dashboard
$dashboard = ResumeX::partner()->getDashboard('last_30_days');

// List all templates
$templates = ResumeX::templates()->list([
    'category' => 'tech',
    'language' => 'vi',
]);

// Get template details
$template = ResumeX::templates()->get('modern-01');

use ResumeX\Exceptions\ResumeXException;
use ResumeX\Facades\ResumeX;

try {
    $cv = ResumeX::cv()->generate([...]);
} catch (ResumeXException $e) {
    // Get error details
    $message = $e->getMessage();
    $errorCode = $e->getErrorCode();
    $statusCode = $e->getStatusCode();

    // Check error type
    if ($e->isRateLimitError()) {
        // Handle rate limiting - wait and retry
    } elseif ($e->isAuthenticationError()) {
        // Invalid API credentials
    } elseif ($e->isValidationError()) {
        // Get validation errors
        $errors = $e->getErrors();
    }

    Log::error('ResumeX API Error', [
        'message' => $message,
        'code' => $errorCode,
        'status' => $statusCode,
    ]);
}



namespace App\Http\Controllers;

use Illuminate\Http\Request;
use ResumeX\Facades\ResumeX;
use ResumeX\Exceptions\ResumeXException;

class ResumeController extends Controller
{
    public function create(Request $request)
    {
        $validated = $request->validate([
            'firstName' => '' => 'array',
            'skills' => 'array',
        ]);

        try {
            $payload = [
                'userId' => (string) $request->user()->id,
                'templateId' => $validated['templateId'],
                'email' => $validated['email'],
                'firstName' => $validated['firstName'],
                'lastName' => $validated['lastName'],
                'phoneNumber' => $validated['phoneNumber'] ?? '',
                'workExperience' => $validated['workExperience'] ?? [],
                'education' => $validated['education'] ?? [],
                'skills' => $validated['skills'] ?? [],
                'preferences' => [
                    'language' => 'en',
                ],
            ];

            $cv = ResumeX::cv()->generate($payload);

            return response()->json([
                'success' => true,
                'cvId' => $cv['cvId'],
                'editorUrl' => $cv['editorUrl'],
            ]);

        } catch (ResumeXException $e) {
            return response()->json([
                'success' => false,
                'error' => $e->getMessage(),
                'errorCode' => $e->getErrorCode(),
            ], $e->getStatusCode() ?? 500);
        }
    }

    /**
     * Create Japanese CV (履歴書)
     */
    public function createJapaneseCv(Request $request)
    {
        $validated = $request->validate([
            'lastName' => '()->json([
            'tier' => $quota['tier'],
            'used' => $quota['used'],
            'remaining' => $quota['remaining'],
            'resetDate' => $quota['resetDate'],
        ]);
    }
}

// routes/api.php
Route::middleware('auth:sanctum')->group(function () {
    Route::post('/resume/create', [ResumeController::class, 'create']);
    Route::get('/resume/quota', [ResumeController::class, 'quota']);
});

$client = new Client([
    'api_key' => 'rx_test_sandbox_key',
    'api_secret' => 'sandbox_secret',
    'environment' => 'sandbox',
]);

use ResumeX\Facades\ResumeX;

public function test_cv_generation()
{
    ResumeX::shouldReceive('cv->generate')
        ->once()
        ->with(\Mockery::type('array'))
        ->andReturn([
            'cvId' => 'cv_test_123',
            'editorUrl' => 'https://app.resumex.com/resumes/cv_test_123?token=xxx',
        ]);

    $response = $this->postJson('/api/resume/create', [
        'fullName' => 'Test User',
        'email' => '[email protected]',
        'phone' => '+84912345678',
    ]);

    $response->assertStatus(200)
        ->assertJsonPath('cvId', 'cv_test_123');
}
bash
php artisan vendor:publish --tag=resumex-config