scholarly/providers
Composer 安装命令:
composer require scholarly/providers
包简介
Unified PHP SDK for scholarly data providers with adapters, caching, and graph exporter.
README 文档
README
Unified PHP SDK for scholarly data providers (OpenAlex, Semantic Scholar, Crossref) with a clean contracts layer, robust HTTP client with retries and caching, and a graph exporter powered by mbsoft/graph-core and mbsoft/graph-algorithms.
✨ Features
- 🔌 Provider adapters: OpenAlex, Semantic Scholar (S2), Crossref
- 🧩 Clean contracts:
Query,Paginator,ScholarlyDataSource - 🔁 Resilient HTTP: jittered backoff, retry-after handling, 4xx/5xx classification
- 🧠 Normalization utils: DOI, arXiv, PubMed, ORCID helpers
- 🗃️ Caching: PSR-16 and PSR-6 support via a simple
CacheLayer - 📈 Graph export: citation and collaboration graphs as mbsoft/graph
Graph - 🧪 Well-tested: Pest test suite, static analysis with PHPStan
- 🧰 Framework-friendly: Laravel service provider + facade
📋 Requirements
- PHP 8.3+
- ext-json, ext-curl
- PSR-18 HTTP client and PSR-17 factories (or use Symfony HttpClient + Nyholm PSR-7)
📦 Installation
Install via Composer:
composer require scholarly/providers
Optional (Laravel): package discovery registers Scholarly\Laravel\ScholarlyServiceProvider. If you disable discovery, register it manually in config/app.php.
🚀 Quick Start
use Scholarly\Contracts\Query; use Scholarly\Factory\AdapterFactory; $factory = AdapterFactory::make(); $openAlex = $factory->adapter('openalex'); // Search works $results = $openAlex->searchWorks(Query::from(['q' => 'graph neural networks', 'limit' => 25])); foreach ($results as $work) { // each $work is array<string, mixed> } // Build a citation graph around a seed set $graph = $factory ->graphExporter($openAlex) ->buildWorkCitationGraph(['openalex:W123'], Query::from(['limit' => 50])); // Export using mbsoft/graph exporters (e.g., Cytoscape JSON) // use Mbsoft\Graph\IO\CytoscapeJsonExporter; // $json = (new CytoscapeJsonExporter())->export($graph);
PSR-first design: inject your own PSR-18 client, PSR-17 factories, PSR-16/PSR-6 cache, or PSR-3 logger via AdapterFactory::make([...], $container).
🔍 Advanced Features
- Caching: wrap a PSR-16 or PSR-6 store with
CacheLayerand pass to the exporter to reuse reference/citation lookups between runs. - Retries & backoff: the client honors
Retry-Afterheaders and applies jittered exponential backoff for transient errors. - Batching & pagination: iterate
Paginatorinstances (searchWorks,listReferences,listCitations) or usebatchWorksByIds. - Identifier helpers:
getWorkByDoi,getWorkByArxiv,getWorkByPubmed,getAuthorByOrcidnormalize inputs and handle not-found paths.
🧱 Architecture
src/Contracts:Queryvalue object,Paginator,ScholarlyDataSourcecontractsrc/Core: HTTP client, backoff, cache layer, identity normalizationsrc/Adapters: OpenAlex, S2, Crossref implementations and paginatorssrc/Exporter: Graph exporter building mbsoft/graphGraphinstancessrc/Factory: Adapter factory, configuration objects, Laravel bindingssrc/Laravel: Service provider and facade
See docs/ for architecture notes, provider specifics, and Laravel usage.
⚙️ Configuration
Environment variables (or publish config/scholarly.php in Laravel):
SCHOLARLY_DEFAULT_ADAPTER(e.g.,openalex)SCHOLARLY_CACHE_STORE(Laravel) or provideCacheInterface/CacheItemPoolInterfaceSCHOLARLY_HTTP_TIMEOUT(seconds)- Provider settings:
OPENALEX_MAILTO,S2_API_KEY,CROSSREF_MAILTO
Graph exporter query flags:
work_ids(seed set),limit(page sizes),max_works(author graph cap),min_collaborations(edge threshold)
🧰 Laravel Usage
use Scholarly\Laravel\Facades\Scholarly; // Resolve the default provider (configured via scholarly.default) $adapter = Scholarly::adapter(); // Export graphs $exporter = Scholarly::graphExporter(); $graph = $exporter->buildWorkCitationGraph(['openalex:W1'], Query::from(['limit' => 50]));
Publish config if needed:
php artisan vendor:publish --tag=scholarly-config
🧪 Testing
Run the test suite:
composer test
With coverage:
composer test-coverage
Static analysis and coding style:
composer stan composer cs-check
Fixtures for provider responses live under tests/Fixtures/. Guard any live API tests with SCHOLARLY_LIVE_TESTS=1.
📚 Documentation
- Start here:
docs/index.md - Quick start guide:
docs/getting-started.md - Contracts reference:
docs/contracts.md - Graphs & algorithms:
docs/graph.md - Adapters:
docs/adapters/openalex.md,docs/adapters/s2.md,docs/adapters/crossref.md - Extending:
docs/extending.md
Hosted docs (GitHub Pages): https://mbsoft31.github.io/scholarly-providers/
🎯 Use Cases
- Research discovery and enrichment workflows
- Building literature citation graphs for analysis/visualization
- Author collaboration network analysis
- Data pipelines integrating multiple scholarly sources via one API
🤝 Contributing
Contributions are welcome! Please open an issue or PR.
- Fork the repository
- Create your feature branch (
git checkout -b feat/awesome) - Ensure quality gates pass (
composer quality) - Push and open a Pull Request
📝 License
This library is open-sourced software licensed under the MIT license.
🔗 See Also
scholarly/providers 适用场景与选型建议
scholarly/providers 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 10 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「sdk」 「graph」 「laravel」 「citation」 「crossref」 「openalex」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 scholarly/providers 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 scholarly/providers 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 scholarly/providers 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Netgen Open Graph Bundle is an Ibexa Platform bundle that allows simple integration with Open Graph protocol.
A tool for scraping URL resources (oEmbed, OpenGraph, Twitter cards, JSON-LD)
Neo4j-PHP-Client is the most advanced PHP Client for Neo4j
Alfabank REST API integration
Creates a date-based SVG graph from an array.
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 29
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-02