PHPackages                             megoxv/laravel-magika - 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. [Security](/categories/security)
4. /
5. megoxv/laravel-magika

ActiveLibrary[Security](/categories/security)

megoxv/laravel-magika
=====================

A Laravel package for file type detection using Google Magika AI.

v1.0.0(1mo ago)6184↑33.3%MITPHPPHP ^8.2

Since Apr 19Pushed 1mo agoCompare

[ Source](https://github.com/megoxv/laravel-magika)[ Packagist](https://packagist.org/packages/megoxv/laravel-magika)[ RSS](/packages/megoxv-laravel-magika/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Laravel Magika AI
=================

[](#laravel-magika-ai)

[![Latest Version on Packagist](https://camo.githubusercontent.com/15055ac5b7fa2d52221874ec4e579b702df82b2ca47198f33952ba7a82fdf7cf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d65676f78762f6c61726176656c2d6d6167696b612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/megoxv/laravel-magika)[![Total Downloads](https://camo.githubusercontent.com/f19f2d1655c21c3e8f000148dcfc516a0a1fb825c8f6a0966c0ec2c943f65aa4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d65676f78762f6c61726176656c2d6d6167696b612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/megoxv/laravel-magika)[![License](https://camo.githubusercontent.com/080a143151564994b5ae3c4f34bc4a2e082ccfcf0bde53ce4a5f3893a9392d15/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d65676f78762f6c61726176656c2d6d6167696b612e7376673f7374796c653d666c61742d737175617265)](https://github.com/megoxv/laravel-magika/blob/main/LICENSE)

**Laravel Magika AI** is a high-performance file type detection package for Laravel. It utilizes Google's **Magika** deep learning model to accurately identify file types based on their content rather than extensions.

---

Key Features
------------

[](#key-features)

- **AI-Powered**: Uses Google's deep learning model (Magika) for 99%+ accuracy.
- **Fast and Lightweight**: Inference takes only a few milliseconds per file.
- **Support for 100+ Formats**: Accurately detects code, documents, archives, and media.
- **Security Focused**: Detects misleading extensions (e.g., PHP code disguised as a JPG).
- **Confidence Scoring**: Require a minimum AI confidence score before accepting uploads.

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

[](#installation)

Install the package via composer:

```
composer require megoxv/laravel-magika
```

Download and install the appropriate Magika binary for your system:

```
php artisan magika:install
```

Check the installation status anytime:

```
php artisan magika:install --status
```

Usage
-----

[](#usage)

### Validation Rule

[](#validation-rule)

Use the `magika` rule in your controllers. You can specify allowed labels and an optional minimum confidence score.

```
// Simple usage (allow only PDF)
$request->validate([
    'document' => 'required|file|magika:pdf'
]);

// With Confidence Threshold (e.g., must be 95% sure it's a PDF)
$request->validate([
    'document' => 'required|file|magika:pdf,0.95'
]);

// Multiple types
$request->validate([
    'profile_image' => 'required|file|magika:png,jpeg,0.9'
]);
```

### Using the Facade

[](#using-the-facade)

```
use Megoxv\LaravelMagika\Facades\Magika;

$result = Magika::predict($path);

echo $result->label;      // e.g., "pdf"
echo $result->mimeType;   // e.g., "application/pdf"
echo $result->score;      // e.g., 0.992
echo $result->isText;     // true/false
```

### Using the Helper

[](#using-the-helper)

```
$result = magika()->predict($path);
```

Configuration
-------------

[](#configuration)

Publish the config file:

```
php artisan vendor:publish --tag="magika-config"
```

License
-------

[](#license)

The MIT License; see [`LICENSE`](LICENSE) for details.

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance90

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community6

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

Unknown

Total

1

Last Release

51d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/87904671?v=4)[Abdelmjid Saber](/maintainers/megoxv)[@megoxv](https://github.com/megoxv)

---

Top Contributors

[![megoxv](https://avatars.githubusercontent.com/u/87904671?v=4)](https://github.com/megoxv "megoxv (2 commits)")

---

Tags

aideep-learningfile-detectionfile-validationlaravel-magikaphp-google-magikasecuritylaravelsecurityaimime-typemagikafile-detection

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/megoxv-laravel-magika/health.svg)

```
[![Health](https://phpackages.com/badges/megoxv-laravel-magika/health.svg)](https://phpackages.com/packages/megoxv-laravel-magika)
```

###  Alternatives

[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.1k91.3M277](/packages/laravel-horizon)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[spatie/laravel-health

Monitor the health of a Laravel application

88011.3M149](/packages/spatie-laravel-health)[dgtlss/warden

A Laravel package that proactively monitors your dependencies for security vulnerabilities by running automated composer audits and sending notifications via webhooks and email

8956.1k](/packages/dgtlss-warden)[mazedlx/laravel-feature-policy

Add Feature-Policy headers to the responses of a Laravel app

17191.4k](/packages/mazedlx-laravel-feature-policy)

PHPackages © 2026

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