PHP code example of scholarly / providers

1. Go to this page and download the library: Download scholarly/providers 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/ */

    

scholarly / providers example snippets


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);

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]));
bash
php artisan vendor:publish --tag=scholarly-config