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)121.9kMITPHPPHP &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 1mo ago

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 77% of packages

Maintenance48

Moderate activity, may be stable

Popularity25

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

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

384d 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

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

20917.2M158](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9346.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

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