PHPackages                             md/phpspec-intelligence-extension - 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. md/phpspec-intelligence-extension

ActivePhpspec-extension[Utility &amp; Helpers](/categories/utility)

md/phpspec-intelligence-extension
=================================

A PhpSpec extension to get a AI suggestion about what to spec next

v1.0.5(1y ago)413MITPHP

Since Sep 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/MarcelloDuarte/phpspec-inteligence-extension)[ Packagist](https://packagist.org/packages/md/phpspec-intelligence-extension)[ RSS](/packages/md-phpspec-intelligence-extension/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (4)Versions (7)Used By (0)

PhpSpec Intelligence Extension
==============================

[](#phpspec-intelligence-extension)

The **PhpSpec Intelligence Extension** introduces a `next` command to PhpSpec, leveraging OpenAI's GPT models to suggest the next specification to implement in your test-driven development workflow.

Table of Contents
-----------------

[](#table-of-contents)

- [Introduction](#introduction)
- [Features](#features)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Examples](#examples)
- [Contributing](#contributing)
- [License](#license)

Introduction
------------

[](#introduction)

Test-driven development (TDD) encourages writing tests before implementing code. However, deciding what to test next can sometimes be challenging. This extension integrates with OpenAI's API to analyze your existing specs and provide intelligent suggestions for the next spec to write, streamlining your TDD process.

Features
--------

[](#features)

- **Automated Spec Suggestions**: Get suggestions for your next spec based on existing specifications.
- **Seamless Integration**: Adds a `next` command to PhpSpec without disrupting your workflow.
- **Configurable Parameters**: Customize API settings like model, max tokens, and temperature.

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

[](#installation)

Install the extension via Composer:

```
composer require --dev md/phpspec-intelligence-extension
```

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

[](#configuration)

To use the extension, you need to:

1. **Enable the Extension**: Add it to your `phpspec.yml` configuration file.
2. **Set the OpenAI API Key**: Provide your OpenAI API key securely.

### 1. Enable the Extension

[](#1-enable-the-extension)

Update your `phpspec.yml` file:

```
extensions:
  Md\PhpSpecIntelligenceExtension\Extension:
    openai_api_key: ~
    openai_api_model: "gpt-3.5-turbo"
    openai_api_temperature: 0.7
    openai_api_max_tokens: 256
```

### 2. Set the OpenAI API Key

[](#2-set-the-openai-api-key)

For security, it's recommended to use environment variables to store your API key.

#### Using Environment Variables

[](#using-environment-variables)

Set the `OPENAI_API_KEY` environment variable in your shell or server configuration.

```
export OPENAI_API_KEY='your-openai-api-key'
```

#### Alternative: Configuration File (Less Secure)

[](#alternative-configuration-file-less-secure)

You can also set the API key in the `phpspec.yml` file (not recommended for shared repositories):

```
extensions:
    Md\PhpSpecIntelligenceExtension\Extension:
        openai_api_key: 'your-openai-api-key'
```

**Warning**: Avoid committing API keys to version control.

Usage
-----

[](#usage)

After installation and configuration, you can use the `next` command:

```
vendor/bin/phpspec next
```

The command will analyze your existing specs and suggest the next one to implement.

### Command Options

[](#command-options)

- `--config`: Specify a custom configuration file.
- `--verbose`: Increase the verbosity of messages.

Example:

```
vendor/bin/phpspec next --config=phpspec.yml --verbose
```

Examples
--------

[](#examples)

### Basic Usage

[](#basic-usage)

```
vendor/bin/phpspec next
```

**Output:**

```
Suggested example for: spec/Acme/MarkdownSpec.php:

    function it_registers_the_next_command(ServiceContainer $container)
    {
        $container->define('console.commands.next',
            Argument::type('Closure'),
            Argument::type('array')
        )->shouldBeCalled();
        $this->load($container, []);
    }

     Would you like me to generate this spec? [Y/n]

```

### Using a Custom Configuration File

[](#using-a-custom-configuration-file)

```
vendor/bin/phpspec next --config=custom-phpspec.yml
```

### Handling API Limits

[](#handling-api-limits)

If you encounter rate limits or quota issues, the command will display an appropriate error message. Ensure your OpenAI account has sufficient quota and consider implementing retry logic if needed.

Contributing
------------

[](#contributing)

Contributions are welcome! Please follow these steps:

1. Fork the repository.
2. Create a new branch for your feature or bugfix.
3. Write specs for your changes.
4. Submit a pull request with a detailed description.

### Running Tests

[](#running-tests)

```
vendor/bin/phpspec run
```

License
-------

[](#license)

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

---

**Note**: This extension uses the OpenAI API, which may incur costs. Monitor your usage to avoid unexpected charges. Always handle API keys securely and follow best practices to protect sensitive information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

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

Every ~0 days

Total

6

Last Release

601d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/70713?v=4)[md](/maintainers/md)[@md](https://github.com/md)

---

Top Contributors

[![MarcelloDuarte](https://avatars.githubusercontent.com/u/144535?v=4)](https://github.com/MarcelloDuarte "MarcelloDuarte (11 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/md-phpspec-intelligence-extension/health.svg)

```
[![Health](https://phpackages.com/badges/md-phpspec-intelligence-extension/health.svg)](https://phpackages.com/packages/md-phpspec-intelligence-extension)
```

###  Alternatives

[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[aedart/athenaeum

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

245.2k](/packages/aedart-athenaeum)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[aeliot/todo-registrar

Register TODOs from source code in issue tracker

153.0k](/packages/aeliot-todo-registrar)

PHPackages © 2026

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