PHPackages                             denason/wikipedia - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. denason/wikipedia

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

denason/wikipedia
=================

A Laravel package to get data and manage information from Wikipedia Directly

v1.0.2(1y ago)122.1kMITPHPPHP &gt;=8.0

Since Apr 24Pushed 1y ago1 watchersCompare

[ Source](https://github.com/DenaSon/wikipedia)[ Packagist](https://packagist.org/packages/denason/wikipedia)[ RSS](/packages/denason-wikipedia/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (5)Used By (0)

Wikipedia Laravel Package
=========================

[](#wikipedia-laravel-package)

📦 A powerful, developer-friendly Laravel package for accessing Wikipedia’s vast knowledge graph. This package bridges the gap between your Laravel application and structured/unstructured content on Wikipedia. Whether you're building educational tools, integrating intelligent search, or enriching content with real-time knowledge, this package gives you full programmatic access to article text, infoboxes, images, and metadata—across multiple languages.

No more dealing with raw API calls! With this package, you can use a fluent interface, full Laravel Facade support, and smart query enhancements to get exactly the data you want.

Features
--------

[](#features)

- Retrieve full article content in HTML, plain text, or summary.
- Fully customizable multi-language support (e.g., English, Persian, French, etc.).
- Smart search and suggestions.
- Extract categories, infobox data, and article images.
- Full support for Facades and Interface-based implementation.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.0
- Laravel &gt;= 9.x

Installation
------------

[](#installation)

```
composer require denason/wikipedia
```

Usage Examples
--------------

[](#usage-examples)

You can use the global `wiki()` helper or dependency injection with the interface to access all features.

### 1. Get article summary

[](#1-get-article-summary)

```
$summary = wiki()->summary('Albert Einstein');
echo $summary;
```

**Output:**

> Albert Einstein was a German-born theoretical physicist who developed the theory of relativity, one of the two pillars of modern physics.

### 2. Get full HTML content

[](#2-get-full-html-content)

```
$html = wiki()->html('Python (programming language)');
```

### 3. Get plain text content

[](#3-get-plain-text-content)

```
$text = wiki()->text('Tehran');
```

### 4. Search with suggestions

[](#4-search-with-suggestions)

```
$results = wiki()->smart()->search('Newton');
```

### 5. Get article image

[](#5-get-article-image)

```
$image = wiki()->imageUrl('Nikola Tesla');
```

### 6. Get categories

[](#6-get-categories)

```
$categories = wiki()->categories('Photosynthesis');
```

- Don't forget to use return to see the output.

### 7. Get infobox data

[](#7-get-infobox-data)

```
 $infobox = wiki()->infoBox('iran');
 foreach ($infobox as $key => $info)
{
    echo $key. '=' . $info;
}
```

### 8. Get description (Wikidata)

[](#8-get-description-wikidata)

```
$desc = wiki()->description('Black hole');
echo $desc;
```

**Output:**

> region of spacetime where gravity is so strong that nothing — not even light — can escape

### 9. Use getInfo for advanced API call

[](#9-use-getinfo-for-advanced-api-call)

```
$data = wiki()->getInfo('Mars', 'extracts', 'json', ['exintro' => true, 'explaintext' => true]);
retutn $data;
```

**Output:**

> Array of raw data based on specified parameters.

### 10. Use extract for custom property

[](#10-use-extract-for-custom-property)

```
$extract = wiki()->extract('Iran', 'extracts', ['explaintext' => true]);
return $extract;
```

**Output:**

> Iran, also called Persia, is a country in Western Asia.

Available Methods
-----------------

[](#available-methods)

All methods are accessible via the `wiki()` helper or through dependency injection using the `WikipediaInterface`.

MethodDescription`summary(title, extra)`Returns a short summary of the article.`html(title)`Retrieves the full article content in HTML.`text(title)`Retrieves the full article content as plain text.`search(query)`Performs a search for related article titles.`suggest(query)`Returns search autocomplete suggestions.`smart()`Enables smart suggestion-based search. If a keyword isn't found, it will return the most relevant alternative suggestion automatically.`lang(code)`Sets the query language (e.g., 'fa', 'en'). Use this when working with non-English titles. For example, for Persian: `wiki()->lang('fa')->summary('دنا');``categories(title)`Returns article categories as an array.`imageUrl(title)`Returns the thumbnail image URL of the article.`url(title)`Returns the full URL to the article.`raw(title)`Returns the raw JSON data from Wikipedia API.`infoBox(title)`Extracts structured data from the article’s infobox.`description(term)`Returns the Wikidata description of the term.`extract(title, prop, extra)`Custom extract call from Wikipedia API.`getInfo(title, prop, format, extra)`General method for accessing Wikipedia API with advanced parameters.📌 How to :

### Dependency Injection Example

[](#dependency-injection-example)

Instead of using the global `wiki()` helper, you can inject the `WikipediaInterface` directly into your controller, service, or job. This is especially useful when writing testable and decoupled code.

#### Example: Using WikipediaInterface in a Controller

[](#example-using-wikipediainterface-in-a-controller)

```
use Denason\Wikipedia\WikipediaInterface;

class ArticleController extends Controller
{
    public function show(WikipediaInterface $wiki)
    {
        $summary = $wiki->summary('Iran');

        return view('article.show', compact('summary'));
    }
}
```

This approach takes advantage of Laravel's service container to resolve the interface to its concrete implementation automatically.

-It also fully supports the Facades

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance45

Moderate activity, may be stable

Popularity26

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

3

Last Release

429d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a97b7fad5fd8fe65af685474b76338d6e0ee01bed343c97a844765c563eecb17?d=identicon)[DenaSon](/maintainers/DenaSon)

---

Top Contributors

[![DenaSon](https://avatars.githubusercontent.com/u/34172621?v=4)](https://github.com/DenaSon "DenaSon (6 commits)")

### Embed Badge

![Health badge](/badges/denason-wikipedia/health.svg)

```
[![Health](https://phpackages.com/badges/denason-wikipedia/health.svg)](https://phpackages.com/packages/denason-wikipedia)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[illuminate/pagination

The Illuminate Pagination package.

12234.1M1.0k](/packages/illuminate-pagination)[illuminate/pipeline

The Illuminate Pipeline package.

9349.2M281](/packages/illuminate-pipeline)[illuminate/broadcasting

The Illuminate Broadcasting package.

7127.2M208](/packages/illuminate-broadcasting)[illuminate/redis

The Illuminate Redis package.

8314.6M374](/packages/illuminate-redis)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
