定制 nativephp/mobile-camera 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

nativephp/mobile-camera

Composer 安装命令:

composer require nativephp/mobile-camera

包简介

Camera plugin for NativePHP Mobile (Photo capture, Video recording, Gallery picker)

README 文档

README

Camera plugin for NativePHP Mobile providing photo capture, video recording, and gallery picker functionality.

Overview

The Camera API provides access to the device's camera for taking photos, recording videos, and selecting media from the gallery.

Installation

composer require nativephp/mobile-camera

Don't forget to register the plugin:

php artisan native:plugin:register nativephp/mobile-camera

Usage

PHP (Livewire/Blade)

use Native\Mobile\Facades\Camera;

// Take a photo
Camera::getPhoto();

// Record a video
Camera::recordVideo();

// Record with max duration
Camera::recordVideo(['maxDuration' => 30]);

// Using fluent API
Camera::recordVideo()
    ->maxDuration(60)
    ->id('my-video-123')
    ->start();

// Pick images from gallery
Camera::pickImages('images', false);  // Single image
Camera::pickImages('images', true);   // Multiple images
Camera::pickImages('all', true);      // Any media type

JavaScript (Vue/React/Inertia)

import { Camera, On, Off, Events } from '#nativephp';

// Take a photo
await Camera.getPhoto();

// With identifier for tracking
await Camera.getPhoto()
    .id('profile-pic');

// Record video
await Camera.recordVideo()
    .maxDuration(60);

// Pick images
await Camera.pickImages()
    .images()
    .multiple()
    .maxItems(5);

Events

PhotoTaken

Fired when a photo is taken with the camera.

PHP

use Native\Mobile\Attributes\OnNative;
use Native\Mobile\Events\Camera\PhotoTaken;

#[OnNative(PhotoTaken::class)]
public function handlePhotoTaken(string $path)
{
    // Process the captured photo
    $this->processPhoto($path);
}

Vue

import { On, Off, Events } from '#nativephp';
import { ref, onMounted, onUnmounted } from 'vue';

const photoPath = ref('');

const handlePhotoTaken = (payload) => {
    photoPath.value = payload.path;
    processPhoto(payload.path);
};

onMounted(() => {
    On(Events.Camera.PhotoTaken, handlePhotoTaken);
});

onUnmounted(() => {
    Off(Events.Camera.PhotoTaken, handlePhotoTaken);
});

VideoRecorded

Fired when a video is successfully recorded.

Payload:

  • string $path - File path to the recorded video
  • string $mimeType - Video MIME type (default: 'video/mp4')
  • ?string $id - Optional identifier if set via id() method

VideoCancelled

Fired when video recording is cancelled by the user.

MediaSelected

Fired when media is selected from the gallery.

use Native\Mobile\Attributes\OnNative;
use Native\Mobile\Events\Gallery\MediaSelected;

#[OnNative(MediaSelected::class)]
public function handleMediaSelected($success, $files, $count)
{
    foreach ($files as $file) {
        $this->processMedia($file);
    }
}

PendingVideoRecorder API

maxDuration(int $seconds)

Set the maximum recording duration in seconds.

id(string $id)

Set a unique identifier for this recording to correlate with events.

event(string $eventClass)

Set a custom event class to dispatch when recording completes.

remember()

Store the recorder's ID in the session for later retrieval.

start()

Explicitly start the video recording.

Storage Locations

Photos:

  • Android: App cache directory at {cache}/captured.jpg
  • iOS: Application Support at ~/Library/Application Support/Photos/captured.jpg

Videos:

  • Android: App cache directory at {cache}/video_{timestamp}.mp4
  • iOS: Application Support at ~/Library/Application Support/Videos/captured_video_{timestamp}.mp4

Notes

  • Permissions: You must enable the camera permission in config/nativephp.php to use camera features
  • If permission is denied, camera functions will fail silently
  • Camera permission is required for photos, videos, AND QR/barcode scanning
  • File formats: JPEG for photos, MP4 for videos

nativephp/mobile-camera 适用场景与选型建议

nativephp/mobile-camera 是一款 基于 Kotlin 开发的 Composer 扩展包,目前已累计 8.61k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2026 年 01 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 nativephp/mobile-camera 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nativephp/mobile-camera 我们能提供哪些服务?
定制开发 / 二次开发

基于 nativephp/mobile-camera 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 8.61k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 13
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 0
  • Forks: 8
  • 开发语言: Kotlin

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-22