PHPackages                             tanghengzhi/midjourney-php - 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. tanghengzhi/midjourney-php

ActiveLibrary

tanghengzhi/midjourney-php
==========================

Generate images using Midjourney Bot through the Discord API.

v2.1.1(2y ago)165MITPHPPHP ^8.1

Since Oct 27Pushed 2y agoCompare

[ Source](https://github.com/tanghengzhi/midjourney-discord-api-php)[ Packagist](https://packagist.org/packages/tanghengzhi/midjourney-php)[ Fund](https://ko-fi.com/ferranfg)[ RSS](/packages/tanghengzhi-midjourney-php/feed)WikiDiscussions main Synced 1mo ago

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

Midjourney PHP Library for Discord API Image Generation
=======================================================

[](#midjourney-php-library-for-discord-api-image-generation)

This PHP library provides a simple interface for generating images using the Midjourney Bot through the Discord API.

[![Midjourney PHP Library for Discord API](/.github/img/demo.gif)](/.github/img/demo.gif)

[![](https://camo.githubusercontent.com/49d5cab41a34562f0f626679e40e0a681b66586b0de2576d2125a00a3fe73ede/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f66657272616e66672f6d69646a6f75726e65792d706870)](https://camo.githubusercontent.com/49d5cab41a34562f0f626679e40e0a681b66586b0de2576d2125a00a3fe73ede/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f66657272616e66672f6d69646a6f75726e65792d706870)[![](https://camo.githubusercontent.com/2250acf5e7aa52f7094e9cf6e1fa5758d32995466c64d81bd1c5b17579785acd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f66657272616e66672f6d69646a6f75726e65792d706870)](https://camo.githubusercontent.com/2250acf5e7aa52f7094e9cf6e1fa5758d32995466c64d81bd1c5b17579785acd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f66657272616e66672f6d69646a6f75726e65792d706870)[![](https://camo.githubusercontent.com/2583112b0dee14073d7c3a3f85fe6bbb10664f3b2a8dbf77ea950f14b6ea5a0b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f66657272616e66672f6d69646a6f75726e65792d706870)](https://camo.githubusercontent.com/2583112b0dee14073d7c3a3f85fe6bbb10664f3b2a8dbf77ea950f14b6ea5a0b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f66657272616e66672f6d69646a6f75726e65792d706870)

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

[](#installation)

You can install this library using Composer. Run the following command in your project directory:

`composer require ferranfg/midjourney-php`

Usage
-----

[](#usage)

### Basic usage

[](#basic-usage)

To generate an image using the Midjourney Bot, you first need to create an instance of the `Midjourney` class:

```
use Ferranfg\MidjourneyPhp\Midjourney;

$midjourney = new Midjourney($discord_channel_id, $discord_user_token);

$message = $midjourney->generate('An astronaut riding a horse');

return $message->upscaled_photo_url;
```

### Constructor

[](#constructor)

- `$discord_channel_id` - Replaces this value with the Channel ID where the Midjourney Bot is installed. You can get the Channel ID right-clicking on the channel and **Copy Channel ID**.

    Remember that you can invite the Midjourney Bot to your own server to organize your work
- `$discord_user_token` - Automatic user accounts (self-bots) are not allowed by Discord and can result in an account termination if found, so use it at your own risk.

    To get your user token, visit  and open the **Network** tab inside the **Developers Tools**. Find between your XHR requests the `Authorization` header.

    [![Discord User Token](/.github/img/authorization.jpg)](/.github/img/authorization.jpg)

### Methods

[](#methods)

#### `$midjourney->imagine($prompt)`

[](#midjourney-imagineprompt)

This method generates an image using a prompt and returns an object that represents the message containing the generated image. The `$prompt` parameter is a string that will be used to generate the image.

```
$imagine_object = $midjourney->imagine('An astronaut riding a horse');
```

#### `$midjourney->getImagine($prompt)`

[](#midjourney-getimagineprompt)

This method returns a previously generated object that represents the message containing the image generated by the given prompt. The `$prompt` parameter is the string used to generate the image.

```
$imagine_object = $midjourney->getImagine('An astronaut riding a horse');
```

#### `$midjourney->upscale($imagine_object, $upscale_index)`

[](#midjourney-upscaleimagine_object-upscale_index)

This method upscales an image contained in the given object and returns the URL of the upscaled image. The `$imagine_object` parameter is the object returned from the `imagine` / `getImagine` methods. The `$upscale_index` parameter is an integer between 0 and 3 that represents the option provided by the MJ bot we want to upscale.

```
$upscaled_image_url = $midjourney->upscale($imagine_object, 2);
```

#### `$midjourney->getUpscale($imagine_object, $upscale_index)`

[](#midjourney-getupscaleimagine_object-upscale_index)

This method returns the URL of a previously upscaled image generated by the given message and with the given option of upscaling. The `$imagine_object` parameter is the object returned from the `imagine` / `getImagine` methods. The `$upscale_index` parameter is an integer between 0 and 3 that represents the option provided to the MJ bot we upscaled.

```
$upscaled_image_url = $midjourney->getUpscale($imagine_object, 2);
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 58.8% 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

928d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f44277cf995e753284479635f054b9c4071feee5c820f6e99a0a18d037deba41?d=identicon)[tanghengzhi](/maintainers/tanghengzhi)

---

Top Contributors

[![tanghengzhi](https://avatars.githubusercontent.com/u/2969338?v=4)](https://github.com/tanghengzhi "tanghengzhi (20 commits)")[![ferranfg](https://avatars.githubusercontent.com/u/195239?v=4)](https://github.com/ferranfg "ferranfg (14 commits)")

---

Tags

midjourneymidjourney-botmidjourney-api-bot

### Embed Badge

![Health badge](/badges/tanghengzhi-midjourney-php/health.svg)

```
[![Health](https://phpackages.com/badges/tanghengzhi-midjourney-php/health.svg)](https://phpackages.com/packages/tanghengzhi-midjourney-php)
```

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k21](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)[batdan/midjourney-api-php

Generate images Midjourney (Discord API). URLs in prompt accepted

222.2k](/packages/batdan-midjourney-api-php)

PHPackages © 2026

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