survos/past-perfect-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

survos/past-perfect-bundle

Composer 安装命令:

composer require survos/past-perfect-bundle

包简介

Symfony bundle for harvesting PastPerfect Online collections

README 文档

README

Symfony bundle for harvesting PastPerfect Online collections.

Streams listing pages and detail pages into JSONL files with built-in resume support via survos/jsonl-bundle sidecars. Raw HTML pages are cached to disk so re-runs are fast.

Site discovery (finding all *.pastperfectonline.com tenants) is delegated to survos/site-discovery-bundle.

Requirements: PHP 8.4+, Symfony 8.0+. Uses Dom\HTMLDocument (PHP 8.4 native HTML5 API) — no external DOM library.

Installation

composer require survos/past-perfect-bundle survos/site-discovery-bundle

Register if not using Flex:

// config/bundles.php
return [
    Survos\SiteDiscoveryBundle\SurvosSiteDiscoveryBundle::class => ['all' => true],
    Survos\PastPerfectBundle\SurvosPastPerfectBundle::class      => ['all' => true],
];

Optional — install survos/import-bundle for field profiling and CSV export:

composer require survos/import-bundle

Configuration

# config/packages/survos_past_perfect.yaml
survos_past_perfect:
    throttle:   1.0                          # seconds between uncached HTTP requests
    cache_dir:  var/pastperfect              # raw HTML cache location
    user_agent: "SurvosPastPerfectBundle Harvester"

Typical workflow

# 1. Find all PPO tenant sites (via Internet Archive CDX)
bin/console pastperfect:discover-registry

# 2. Validate each site is live (dispatches Messenger messages)
bin/console pastperfect:probe-registry

# 3. Harvest the listing index for one site
bin/console pastperfect:harvest-listing https://fauquierhistory.pastperfectonline.com

# 4. Fetch and parse all detail pages (HTML cached locally)
bin/console pastperfect:harvest-details \
    var/pastperfect/fauquierhistory/fauquierhistory-listing.jsonl

# 5. Review the field landscape (requires survos/import-bundle)
bin/console import:profile:report \
    var/pastperfect/fauquierhistory/fauquierhistory-details.jsonl.profile.json

Commands

pastperfect:discover-registry

Queries the Internet Archive CDX API for all *.pastperfectonline.com tenant hostnames and writes a registry listing JSONL. Delegates to CdxDiscoveryService from survos/site-discovery-bundle.

bin/console pastperfect:discover-registry [options]
Option Default Description
--output var/pastperfect/registry-listing.jsonl Output path
--force false Re-discover even if file is already complete
--limit 0 Stop after N sites (0 = unlimited). Use during development.
# Test with 5 sites
bin/console pastperfect:discover-registry --limit=5

# Full discovery (slow — CDX pages take 10–30 s each)
bin/console pastperfect:discover-registry

Each record:

{
  "slug":          "fauquierhistory",
  "host":          "fauquierhistory.pastperfectonline.com",
  "base_url":      "https://fauquierhistory.pastperfectonline.com",
  "discovered_via": "internet_archive_cdx",
  "validated":     false,
  "validated_at":  null
}

pastperfect:probe-registry

Reads the registry listing and dispatches one ProbeRegistrySiteMessage per site. Each message validates the host is a live PPO site and writes the result to a probed registry JSONL.

Configure Symfony Messenger to handle the messages asynchronously, or leave unrouted for synchronous handling:

# config/packages/messenger.yaml
framework:
    messenger:
        routing:
            Survos\PastPerfectBundle\Message\ProbeRegistrySiteMessage: async
            Survos\PastPerfectBundle\Message\ProbeItemMessage:         async
bin/console pastperfect:probe-registry [listingFile] [options]
Argument Default Description
listingFile var/pastperfect/registry-listing.jsonl Input listing JSONL
Option Default Description
--output {dir}/registry-probed.jsonl Output path
--force false Re-probe all sites
--limit 0 Stop after N sites

pastperfect:harvest-listing

Fetches the AdvancedSearch listing pages, parses all record links, and writes a listing JSONL. Resumes automatically on re-run (sidecar tracks progress).

bin/console pastperfect:harvest-listing <baseUrl> [options]
Argument Description
baseUrl e.g. https://fauquierhistory.pastperfectonline.com
Option Default Description
--output-dir var/pastperfect Output directory
--force false Re-harvest even if complete

Output: {output-dir}/{site}/{site}-listing.jsonl

Each record:

{
  "source": "pastperfectonline",
  "site":   "fauquierhistory",
  "type":   "webobject",
  "id":     "AC429E12-B023-4E3D-BEC0-693892645021",
  "url":    "https://fauquierhistory.pastperfectonline.com/webobject/AC429E12-..."
}

pastperfect:harvest-details

Reads the listing JSONL, fetches each detail page (cached under {cache_dir}/{site}/detail/), parses catalog fields, and writes a flat details JSONL. A .profile.json is written automatically after every run.

bin/console pastperfect:harvest-details <listingFile> [options]
Argument Description
listingFile Path to listing JSONL from harvest-listing
Option Default Description
--output-dir same dir as listing file Output directory
--force false Re-fetch all, ignoring cache
--profile-only false Only (re-)profile the existing JSONL
--limit 0 Stop after N records

Output files:

  • {site}-details.jsonl — one flat record per item
  • {site}-details.jsonl.profile.json — field profile
# Full harvest (cached HTML means re-runs are fast)
bin/console pastperfect:harvest-details \
    var/pastperfect/fauquierhistory/fauquierhistory-listing.jsonl

# Test with 10 records
bin/console pastperfect:harvest-details \
    var/pastperfect/fauquierhistory/fauquierhistory-listing.jsonl --limit=10

# Re-profile without any HTTP requests
bin/console pastperfect:harvest-details \
    var/pastperfect/fauquierhistory/fauquierhistory-listing.jsonl --profile-only

About rights and licensing

PastPerfect Online has no dedicated rights or license field in its catalog schema. The only rights signal is the footer copyright notice on each page, e.g.:

© Fauquier Historical Society 2021

This is captured as rights_notice in every detail record. It is a site-level attribution, not item-level.

Government-operated PPO sites may publish under a permissive or CC license, but PPO itself provides no mechanism to declare this. Rights decisions must be made at the application level, using rights_notice plus out-of-band knowledge about the institution.

Analysing harvested fields

# Review field landscape (requires survos/import-bundle)
bin/console import:profile:report \
    var/pastperfect/fauquierhistory/fauquierhistory-details.jsonl.profile.json

# Sort by distinct value count
bin/console import:profile:report ... --sort=distinct

# Show fields that look like delimited lists
bin/console import:profile:report ... --only=split

# Re-generate the profile at any time
bin/console pastperfect:harvest-details fauquierhistory-listing.jsonl --profile-only

Messenger messages

Two messages are available for async processing:

Message Dispatched by Handler
ProbeRegistrySiteMessage pastperfect:probe-registry ProbeRegistrySiteHandler
ProbeItemMessage (dispatch manually) ProbeItemHandler

Route to any Symfony Messenger transport — Doctrine, AMQP, Redis, etc. Leave unrouted for synchronous in-process handling (useful for small sites or testing).

License

MIT

survos/past-perfect-bundle 适用场景与选型建议

survos/past-perfect-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 333 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「symfony」 「Harvest」 「jsonl」 「pastperfect」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 survos/past-perfect-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 survos/past-perfect-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 survos/past-perfect-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 333
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 32
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-04