pushinbr / pam-crawl
Fast, browserless web crawler and scraper for PHP on PAM: clean Markdown for LLMs, typed extraction, deep crawling.
Requires
- php: ^8.5
- ext-curl: *
- ext-dom: *
- ext-mbstring: *
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
Suggests
- ext-intl: IDN host normalization
- ext-pdo_sqlite: Persistent HTTP cache and incremental recrawl
Provides
None
Conflicts
None
Replaces
None
README
🕸️ PAM Crawl
The fastest way to turn the web into clean, LLM-ready data — in PHP.
Markdown for RAG · typed extraction · deep crawls · LLM extraction · CLI · HTTP API · MCP
Documentation · Start here · Examples · Features · Docs · vs crawl4ai · Benchmarks
460 real pages, Markdown + fit Markdown + links + media for every page. Methodology and raw numbers.
PAM Crawl is a PHP re-implementation of crawl4ai with every one of its features — and a different engine underneath. Instead of opening a browser for every page, it speaks HTTP/2 directly, parses with a native HTML5 parser and only reaches for a browser when a page truly needs JavaScript.
- ⚡ ~20× faster, ~40× lighter. HTTP/2 multiplexing, lazy per-page parsing, bounded memory.
Scale across CPU cores with
->workers(8). - 🧠 Built for LLMs. Clean Markdown, main-content extraction, BM25 focus, citations, chunking, and LLM extraction/Q&A with OpenAI, Anthropic, Gemini or a local Ollama.
- 🧩 Typed by design. Hydrate your own PHP objects with attributes —
#[Css('.price'), JsonLd('offers.price'), Money] public int $cents. - 🧭 Reads JavaScript apps without a browser. Next.js/Nuxt/Remix hydration data and the
JSON APIs behind a page. Need real rendering? Add
pam-crawl-browser. - 🔌 Plugs in anywhere. Library,
crawlCLI, crawl4ai-compatible HTTP API, MCP server, Docker.
Start here
1. Install PAM
curl --proto '=https' --proto-redir '=https' --tlsv1.2 \ --connect-timeout 15 --max-time 60 --max-filesize 1048576 -fsSL \ https://pamphp.com/install | sh pam doctor
2. Create your project
mkdir my-crawler && cd my-crawler pam composer init --no-interaction pam composer require pushinbr/pam-crawl:^0.1
3. Create crawl.php
<?php declare(strict_types=1); require __DIR__.'/vendor/autoload.php'; use Pam\Crawl\Crawl; use Pam\Crawl\Page; // One page -> clean Markdown for an LLM $page = Crawl::url('https://www.php.net/manual/en/function.array-map.php')->get(); echo $page->content->raw, "\n"; // main content only (crawl4ai fit_markdown) echo $page->markdown(focus: 'callback'), "\n"; // BM25: only the sections about the query // A docs section, 32 requests in flight, streamed as pages complete Crawl::site('https://www.php.net/manual/en/') ->only('/manual/en/*') ->depth(2)->limit(20) ->concurrency(32) ->cache() // ./.cache/pam-crawl.sqlite, ETag revalidation ->each(function (Page $p): void { printf("%d %-60s %5d words\n", $p->status, $p->url, $p->wordCount); });
4. Run it
pam crawl.php
More than 25 runnable scripts live in examples/ — from a single page to
adaptive crawls and LLM extraction.
A quick tour
|
Clean Markdown for RAG $page = Crawl::url($url)->get(); $page->markdown->raw; // full page $page->content->raw; // main content only $page->markdown(focus: 'pricing plans'); // BM25 $page->markdown(citations: true); // text⟨1⟩ + references |
Typed extraction into your classes #[Item('article.product_pod')] final readonly class Book { public function __construct( #[Css('h3 a', attr: 'title')] public string $title, #[Css('.price_color'), Money] public int $cents, #[Css('.availability')] public bool $inStock, ) {} } $books = Crawl::url($shop)->get()->extractAll(Book::class); |
|
Deep crawl, smartly prioritized Crawl::site('https://docs.example.com') ->only('/docs/*')->except('*/changelog/*') ->prioritize(Score::keywords('auth', 'tokens')) ->depth(3)->limit(200) ->respectRobots() ->onPage(new Jsonl('docs.jsonl')) ->each(fn (Page $p) => $index->add($p->content->raw)); |
Use every core $summaries = Crawl::urls($tenThousandUrls) ->workers(8) // processes ->concurrency(32) // HTTP/2 streams each ->map(fn (Page $p) => [ 'url' => $p->url, 'title' => $p->meta->title, 'words' => $p->wordCount, ]); |
|
LLM extraction & Q&A (OpenAI, Anthropic, Gemini, Ollama…) $llm = new Config('ollama/qwen2.5:7b'); $offers = (new LlmExtraction($llm, 'all offers', Offer::class)) ->extract($page); // list<Offer> $answer = (new Ask($llm))->ask($page, 'When was it proposed?'); echo $answer->text; // … in February 1994 ⟨3⟩ |
JavaScript apps, without a browser $page->embedded['next']; // Next.js / Nuxt / Remix data $page->api(); // JSON APIs behind the page $page->isShell; // needs real rendering? // with pushinbr/pam-crawl-browser installed: Crawl::url($spa)->render()->get(); // only when needed Crawl::url($url)->browser()->screenshot()->get(); |
Features
| Fetching | HTTP/2 multiplexing on curl_multi, keep-alive, br/zstd/gzip, per-host limits and politeness, adaptive back-off on 429/503, Retry-After, robots.txt (RFC 9309), proxy rotation, cookie sessions, realistic user agents with client hints, bot-wall detection with proxy retry and fallback(), downloads streamed to disk, TLS certificates |
| Cache | SQLite HTTP cache with ETag/Last-Modified revalidation; crawl4ai cache modes |
| Content | GFM Markdown with citations, main-content extraction, pruning and BM25 filters, LLM filter, selector() / target() / exclude() |
| Page data | links with context, scored images, video/audio, tables (rowspan/colspan), metadata, OpenGraph, JSON-LD, RSS/Atom, JSON, PDF |
| Extraction | attribute-driven DTOs with fallback chains, crawl4ai CSS/XPath JSON schemas, regex library, 7 chunking strategies, cosine clustering |
| LLM | extraction into DTOs, schema generation with validation, learn once (the LLM writes the selectors, later pages run without it), tables, Q&A with citations, embeddings |
| Crawling | BFS / DFS / best-first, URL filters and scorers, sitemap + Common Crawl seeding, link preview, domain mapper, adaptive crawling (statistical and embedding), per-URL rules, near-duplicate skipping |
| JavaScript | hydration data (Next, Nuxt, Remix, Apollo…), API discovery, app-shell detection; real rendering through pam-crawl-browser (Lightpanda or Chrome) |
| Operations | change monitoring with diffs, live Stats, JSONL/CSV export, multi-process workers(), warm connections and caches in persistent PAM workers |
| Interfaces | crawl CLI (crwl-compatible), crawl4ai-compatible HTTP API with jobs and webhooks, playground and dashboard, MCP (stdio, HTTP, SSE), Docker image |
Documentation
| Topic | |
|---|---|
| 📚 Examples | 25+ scripts you can run right away |
| ⌨️ Command line | crawl, settings, seeding, mapping, browsers and profiles |
| 🌐 HTTP API and Docker | endpoints, jobs, webhooks, auth, SSRF guard, container |
| 🤖 MCP server | tools and transports for AI assistants |
| 🧠 LLM features | providers, extraction, Q&A, embeddings, local models |
| 🧩 Extraction | typed DTOs, C4A-Script, crawler hub |
| 🧭 JavaScript pages | hydration data, API discovery, rendering |
| 🔁 Coming from crawl4ai | concept-by-concept mapping |
| 🏗️ Architecture and testing | how it fits together, running outside PAM |
| 📈 Benchmarks | methodology and raw results |
Packages
| Package | |
|---|---|
pushinbr/pam-crawl |
this package — the browserless crawler, everything above |
pushinbr/pam-crawl-browser |
optional JavaScript renderer: Lightpanda or Chrome, screenshots, PDF, sessions |
Responsible use
Respect robots.txt (->respectRobots(), --robots), keep per-host concurrency and delays
polite, identify your crawler when appropriate, and follow each site's terms of service and
applicable law.
License
Open source under the Apache License 2.0. See NOTICE.
This product includes software developed by UncleCode (https://x.com/unclecode) as part of the Crawl4AI project (https://github.com/unclecode/crawl4ai).