molbal/ai-phpdoc

Writes missing PHPDoc comments using GPT-3.

1.0.7 2023-01-09 19:32 UTC

README

Code example

Total Downloads Latest Version License

Cute icon. You like it! AI PHPDocs

AI PHPDocs is a tool that uses GPT-3 to automatically add missing PHPDoc comments to your PHP code.

Demo video: https://youtu.be/bu-fkRyLQaI

Example output: https://github.com/molbal/abyss-tracker/commit/e4013c7533aa7ca855176ddce9f3563a011cdc0f

Prerequisites

This package uses the OpenAI API. Before using AI PHPDocs, you will need to have an OpenAI API key set as an environment variable.

export OPENAI_KEY=...

You can get an API key at https://beta.openai.com/account/api-keys

Installation

To install AI PHPDocs, run the following command:

composer global require molbal/ai-phpdoc

Usage

To add missing PHPDoc comments to a single file, use the following command:

aiphpdocs file  /path/to/file.php

To add missing PHPDoc comments to a directory of files, use the following command. By default it iterates through the current directory for all files, but does not go into subdirectories:

aiphpdocs dir

You may set the --recursive flag, or -r for short for it to go into subdirectories.

If you pass another variable (regardless of the recursive flag) it will treat it as another directory to sweep through instead of the working directory.

aiphpdocs dir -r /somewhere/else

License

AI PHPDocs is licensed under the AGPL-3.0 license. See LICENSE for more information.