PHPackages                             nativephp/mobile-microphone - 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. nativephp/mobile-microphone

ActiveNativephp-plugin[Utility &amp; Helpers](/categories/utility)

nativephp/mobile-microphone
===========================

Microphone recording plugin for NativePHP Mobile - audio recording with pause/resume support

1.0.1(1mo ago)1422↑83.3%1MITKotlinPHP ^8.2

Since Jan 19Pushed 1mo agoCompare

[ Source](https://github.com/NativePHP/mobile-microphone)[ Packagist](https://packagist.org/packages/nativephp/mobile-microphone)[ RSS](/packages/nativephp-mobile-microphone/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Microphone Plugin for NativePHP Mobile
======================================

[](#microphone-plugin-for-nativephp-mobile)

Audio recording plugin for NativePHP Mobile with pause/resume support, background recording, and native permission handling.

Overview
--------

[](#overview)

The Microphone API provides access to the device's microphone for recording audio. It offers a fluent interface for starting and managing recordings, tracking them with unique identifiers, and responding to completion events.

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

[](#installation)

```
composer require nativephp/mobile-microphone
```

Usage
-----

[](#usage)

### PHP (Livewire/Blade)

[](#php-livewireblade)

```
use Native\Mobile\Facades\Microphone;

// Start recording
Microphone::record()->start();

// Stop recording
Microphone::stop();

// Pause recording
Microphone::pause();

// Resume recording
Microphone::resume();

// Get status
$status = Microphone::getStatus();
// Returns: "idle", "recording", or "paused"

// Get last recording path
$path = Microphone::getRecording();
```

### JavaScript (Vue/React/Inertia)

[](#javascript-vuereactinertia)

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

// Basic recording
await Microphone.record();

// With identifier for tracking
await Microphone.record()
    .id('voice-memo');

// Stop recording
await Microphone.stop();

// Pause/resume
await Microphone.pause();
await Microphone.resume();

// Get status
const result = await Microphone.getStatus();
if (result.status === 'recording') {
    // Recording in progress
}

// Get last recording
const result = await Microphone.getRecording();
if (result.path) {
    // Process the recording
}
```

PendingMicrophone API
---------------------

[](#pendingmicrophone-api)

### `id(string $id)`

[](#idstring-id)

Set a unique identifier for this recording.

```
Microphone::record()
    ->id('voice-note-123')
    ->start();
```

### `event(string $eventClass)`

[](#eventstring-eventclass)

Set a custom event class to dispatch when recording completes.

```
use App\Events\VoiceMessageRecorded;

Microphone::record()
    ->event(VoiceMessageRecorded::class)
    ->start();
```

### `remember()`

[](#remember)

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

```
Microphone::record()
    ->id('voice-note')
    ->remember()
    ->start();
```

### `start()`

[](#start)

Explicitly start the audio recording. Returns `true` if recording started successfully.

Events
------

[](#events)

### `MicrophoneRecorded`

[](#microphonerecorded)

Dispatched when an audio recording completes.

**Payload:**

- `string $path` - File path to the recorded audio
- `string $mimeType` - MIME type of the audio (default: `'audio/m4a'`)
- `?string $id` - The recorder's ID, if one was set

#### PHP

[](#php)

```
use Native\Mobile\Attributes\OnNative;
use Native\Mobile\Events\Microphone\MicrophoneRecorded;

#[OnNative(MicrophoneRecorded::class)]
public function handleAudioRecorded(string $path, string $mimeType, ?string $id)
{
    $this->recordings[] = [
        'path' => $path,
        'mimeType' => $mimeType,
        'id' => $id,
    ];
}
```

#### Vue

[](#vue)

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

const recordings = ref([]);

const handleAudioRecorded = (payload) => {
    const { path, mimeType, id } = payload;
    recordings.value.push({ path, mimeType, id });
};

onMounted(() => {
    On(Events.Microphone.MicrophoneRecorded, handleAudioRecorded);
});

onUnmounted(() => {
    Off(Events.Microphone.MicrophoneRecorded, handleAudioRecorded);
});
```

#### React

[](#react)

```
import { On, Off, Events } from '#nativephp';
import { useState, useEffect } from 'react';

const [recordings, setRecordings] = useState([]);

const handleAudioRecorded = (payload) => {
    const { path, mimeType, id } = payload;
    setRecordings(prev => [...prev, { path, mimeType, id }]);
};

useEffect(() => {
    On(Events.Microphone.MicrophoneRecorded, handleAudioRecorded);

    return () => {
        Off(Events.Microphone.MicrophoneRecorded, handleAudioRecorded);
    };
}, []);
```

Notes
-----

[](#notes)

- **Microphone Permission:** The first time your app requests microphone access, users will be prompted for permission. If denied, recording functions will fail silently.
- **Background Recording:** You can allow your app to record audio while the device is locked by toggling `microphone_background` to true in the config.
- **File Format:** Recordings are stored as M4A/AAC audio files (`.m4a`). This format is optimized for small file sizes while maintaining quality.
- **Recording State:** Only one recording can be active at a time. Calling `start()` while a recording is in progress will return `false`.
- **Auto-Start Behavior:** If you don't explicitly call `start()`, the recording will automatically start when the `PendingMicrophone` is destroyed.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance88

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% 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 ~59 days

Total

2

Last Release

59d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ab43d3432a80f0f41fe7015280f6024ff13fe8c2306cf114a1fbc91a4cd6f35?d=identicon)[simonhamp](/maintainers/simonhamp)

---

Top Contributors

[![shanerbaner82](https://avatars.githubusercontent.com/u/5580860?v=4)](https://github.com/shanerbaner82 "shanerbaner82 (15 commits)")[![simonhamp](https://avatars.githubusercontent.com/u/31628?v=4)](https://github.com/simonhamp "simonhamp (3 commits)")

---

Tags

nativephpnativephp-mobilenativephp-plugin

### Embed Badge

![Health badge](/badges/nativephp-mobile-microphone/health.svg)

```
[![Health](https://phpackages.com/badges/nativephp-mobile-microphone/health.svg)](https://phpackages.com/packages/nativephp-mobile-microphone)
```

###  Alternatives

[localheinz/diff

Fork of sebastian/diff for use with ergebnis/composer-normalize

4737.0M5](/packages/localheinz-diff)[jeroendesloovere/vcard-bundle

This Symfony 2 bundle can generate vCards with lots of data. When using an &lt; iOS 7 device it will export as a .ics file because iOS devices don't support the default .vcf files.

1677.3k3](/packages/jeroendesloovere-vcard-bundle)

PHPackages © 2026

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