PHP guide

How to Parse Resumes in PHP and WordPress

Turn PDF and DOCX resumes into structured data from PHP with one function and the built-in cURL extension. Works in plain PHP, Laravel and WordPress. The code was run against the live API on PHP 8.2, and the outputs are what it printed.

What you need

1. The parse_resume() function

Parsing is asynchronous: the upload returns a candidate id straight away and the result is ready a few seconds later. This file wraps both steps. It reads your key from a CVPP_API_KEY constant (handy in WordPress) or environment variable.

parse_resume.php
<?php
const CVPP_API = 'https://cvparserpro.com/api/v1';

function cvpp_request(string $method, string $path, ?array $fields = null): array
{
    $ch = curl_init(CVPP_API . $path);
    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        // WordPress: define('CVPP_API_KEY', 'ts_...') in wp-config.php. Elsewhere: an environment variable.
        CURLOPT_HTTPHEADER => ['X-API-Key: ' . (defined('CVPP_API_KEY') ? CVPP_API_KEY : getenv('CVPP_API_KEY'))],
        CURLOPT_CUSTOMREQUEST => $method,
        CURLOPT_TIMEOUT => 60,
    ]);
    if ($fields !== null) {
        curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
    }
    $body = curl_exec($ch);
    $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    if ($body === false || $status >= 400) {
        throw new RuntimeException("CV Parser Pro API error $status: $body");
    }
    return json_decode($body, true);
}

function parse_resume(string $path, int $timeout = 120): array
{
    // 1. Upload the file (field name "files")
    $upload = cvpp_request('POST', '/parse', ['files' => new CURLFile($path)]);
    $id = $upload['candidates'][0]['id'];

    // 2. Poll until parsing finishes
    $deadline = time() + $timeout;
    while (time() < $deadline) {
        $data = cvpp_request('GET', "/candidates/$id")['data'];
        if ($data['parsing_status'] === 'completed') {
            return $data;
        }
        if ($data['parsing_status'] === 'failed') {
            throw new RuntimeException(json_encode($data['parsing_errors']));
        }
        sleep(3);
    }
    throw new RuntimeException("Resume $id was not parsed within {$timeout}s");
}

2. Parse one resume

example.php
<?php
require 'parse_resume.php';

$resume = parse_resume('resume.pdf');
echo $resume['full_name'], ' - ', $resume['current_title'], PHP_EOL;
foreach ($resume['work_history'] as $job) {
    echo "{$job['start_date']} to {$job['end_date']}: {$job['title']} at {$job['company']}", PHP_EOL;
}
Maria Lopez - Senior Backend Engineer
2021-03 to present: Senior Backend Engineer at Northwind Logistics
2018-01 to 2021-02: Software Engineer at Brightline Health

The result also includes email, phone, location, education, certifications, skills, spoken languages, a summary and confidence scores. See every field.

3. Parse a folder into a CSV

batch.php
<?php
require 'parse_resume.php';

$out = fopen('candidates.csv', 'w');
fputcsv($out, ['file', 'name', 'email', 'title', 'years', 'skills']);
$count = 0;

foreach (glob('resumes/*.{pdf,docx}', GLOB_BRACE) as $path) {
    try {
        $r = parse_resume($path);
        fputcsv($out, [basename($path), $r['full_name'], $r['email'], $r['current_title'],
                       $r['years_of_experience'], implode(', ', $r['skills'] ?? [])]);
        $count++;
    } catch (RuntimeException $e) {
        echo basename($path), ': ', $e->getMessage(), PHP_EOL;
    }
}

fclose($out);
echo "Saved $count candidates to candidates.csv", PHP_EOL;
file,name,email,title,years,skills
maria.docx,"Maria Lopez",[email protected],"Senior Backend Engineer",7,"Python, Go, PostgreSQL, Kubernetes, AWS, Apache Kafka, Docker"
maria.pdf,"Maria Lopez",[email protected],"Senior Backend Engineer",7,"Python, Go, PostgreSQL, Kubernetes, AWS, Apache Kafka, Docker"

4. Use it in WordPress

  1. Add your key to wp-config.php: define('CVPP_API_KEY', 'ts_your_api_key');
  2. Copy parse_resume.php into your plugin or child theme and require it.
  3. In your form plugin's "after submission" hook, pass the uploaded file's path on disk to parse_resume() and save the fields you need, for example as post meta on the application.
  4. Because parsing takes 10 to 25 seconds, schedule it with wp_schedule_single_event() instead of making the applicant wait, or skip polling entirely and receive a signed webhook when each resume is done.

Never put the API key in JavaScript or theme templates that reach the browser; keep it in wp-config.php on the server.

Get your API key

10 free parses. No credit card. No expiry.

Create a free account

Frequently Asked Questions

Getting reliable text out of PDFs in pure PHP is hard, and turning that text into job history and skills is harder. The simplest route is to send the file to a resume parser API with PHP’s built-in cURL extension, which is what this guide does.

Usually, yes. It only needs the PHP cURL extension, which most hosts enable. Parsing takes 10 to 25 seconds, so run it after the form submission is saved (or in a scheduled task) rather than making the visitor wait.

The code was tested on PHP 8.2 and uses features available from PHP 7.4 onward.