PHPackages                             kpion/spaghetti - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. kpion/spaghetti

ActiveProject[Parsing &amp; Serialization](/categories/parsing)

kpion/spaghetti
===============

Spaghetti - making Markdown with PHP

v1.0.5(1y ago)28MITPHPPHP ^7.4|^8.0

Since Nov 21Pushed 1y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (7)Used By (0)

🍝 Spaghetti - Low Calorie Documentation Tool
============================================

[](#-spaghetti---low-calorie-documentation-tool)

Automate explaining your code to AI (and maybe humans).

Creating documentation is such a joyride. Especially when you need to keep your documentation up-to-date with the latest code or database schema, perhaps to feed an AI model or to ensure that your team always has access to the most accurate information.

There's nothing quite like manually copying and pasting code snippets to really brighten your day.

Because let's face it, who doesn't love the relaxing experience of executing `SHOW CREATE TABLE user` and then transferring the result to a doc file every time you need an updated document? After all, what could be more calming than mindlessly copying and pasting for hours on end.

Oh, and you also proably believe you will never again create a spaghetti code in your live.

We are here to ruin all the fun :)

Spaghetti is a tool designed to simplify the creation of project documentation, especially useful for generating structured content for AI review (prompts). It works by authoring Markdown files enriched with dynamic content generated by PHP, automating repetitive tasks such as inserting database information.

Unlike full-scale documentation tools like phpDocumentor or Sphinx which focus on entire projects, Spaghetti is designed for narrower, context-specific tasks. You can easily combine your **own explanations** with **dynamically generated content** such as:

- Database table schemas
- Code snippets from specific files
- Directory structures

Example Usage
-------------

[](#example-usage)

### Create a file like **about-pet-project.spaghetti.php**:

[](#create-a-file-like-about-pet-projectspaghettiphp)

> \# *Pet Adoption Project*
>
> *Example description: This is a simple project for managing a pet adoption database. It includes tables for storing information about pets, their sweetness level (subjective but fun!), and more.*

### Now create your main file, **index.spaghetti.php**:

[](#now-create-your-main-file-indexspaghettiphp)

> *``*
>
> *The most important table in this project is `pet`. Here's its structure:*
>
> *``*
>
> *It’s related to the `sweetness` table, which evaluates how adorable each pet is:*
>
> *``*
>
> *Each pet is represented by the `Pet` entity:*
>
> *``*

### Finally, build the documentation using Spaghetti:

[](#finally-build-the-documentation-using-spaghetti)

```
spaghetti index.spaghetti.php > index.md
```

This will generate a Markdown file (`index.md`) with all your descriptions, database schemas, and entity code snippets combined.

### Alternatively, you can pass it directly to another application, such as an AI model

[](#alternatively-you-can-pass-it-directly-to-another-application-such-as-an-ai-model)

```
ollama run llama3.2 "Could you please review my project?\
I’m looking for feedback on\
the code quality, suggestions for improvements,\
and insights on whether the design patterns used\
are appropriate.\
Here are the details: $(spaghetti prompts/index.spaghetti.php)"
```

This way, you can start your day with a cup of coffee and a single command, `spaghetti` ensures the information returned is up-to-date :)

Example output
--------------

[](#example-output)

The above example will result in a markdown file similar to this:

\# **Pet Adoption Project**

This is a simple project for managing a pet adoption (...)

The most important table in this project is `pet`. Here's its structure:

ColumnTypeDescriptionidintPrimary keynamevarcharName of the pet.........It’s related to the `sweetness` table, which evaluates how adorable each pet is:

ColumnTypeDescriptionidintPrimary keypet\_idintForeign key referencing `pet`levelintSweetness level of the pet.........Each pet is represented by the `Pet` entity:

```
class Pet {
    private $id;
    private $name;
    // ...
}
```

**...End of example output**

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

[](#installation)

Note

Installing Spaghetti as a regular Composer dependency is not recommended. Spaghetti is a tool, not a library. As such, it should be installed as a standalone package, so that Spaghetti's dependencies do not interfere with your project's dependencies.

Install globally with Composer:

```
composer global require kpion/spaghetti
```

Make sure your global Composer binaries directory\* is in your system's PATH. Because lost spaghetti is sad spaghetti.

\* Usually, on Ubuntu, Composer binaries are located either in *~/.config/composer/vendor/bin/* or *~/.composer/vendor/bin/*.

Details
-------

[](#details)

### Including Other Spaghetti files

[](#including-other-spaghetti-files)

Easily include and parse contents of other **spaghetti** files.

```
