承接 megoxv/laravel-magika 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

megoxv/laravel-magika

Composer 安装命令:

composer require megoxv/laravel-magika

包简介

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

README 文档

README

Latest Version on Packagist Total Downloads 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

  • 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

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

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

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

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

Configuration

Publish the config file:

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

License

The MIT License; see LICENSE for details.

统计信息

  • 总下载量: 269
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固