PHPackages                             richbrains/ai-textarea - 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. richbrains/ai-textarea

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

richbrains/ai-textarea
======================

AI-powered textarea for Symfony as a dedicated form type with a clean modal UI. Let users rewrite text using an OpenAI‑compatible API.

v0.1.0(7mo ago)01MITJavaScriptPHP &gt;=8.1

Since Sep 21Pushed 7mo agoCompare

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

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

AI Textarea Bundle
==================

[](#ai-textarea-bundle)

AI-powered textarea for Symfony as a dedicated form type with a clean modal UI. Let users rewrite text (friendlier, more professional, fix grammar, shorter/longer) using an OpenAI‑compatible API.

Features
--------

[](#features)

- New form type: `AITextareaType` (opt‑in per field)
- Modal UI with quick-action chips, custom prompt, preview, Copy and Replace buttons
- No external CSS/JS frameworks; ships minimal assets
- Uses Symfony HttpClient; config via Symfony config/env
- CSRF-protected backend endpoint
- Works with OpenAI or any OpenAI‑compatible server (`base_url`)

Requirements
------------

[](#requirements)

- PHP &gt;= 8.1
- Symfony ^5.4 | ^6.0 | ^7.0
- Packages: `symfony/framework-bundle`, `symfony/form`, `symfony/http-client`, `symfony/twig-bundle`, `symfony/security-csrf`, `symfony/asset`

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

[](#installation)

Install via Composer:

```
composer require richbrains/ai-textarea
```

If you don’t use Symfony Flex, enable the bundle:

```
// config/bundles.php
return [
    // ...
    RichBrains\AITextarea\AITextareaBundle::class => ['all' => true],
];
```

Import routes:

```
# config/routes/ai_textarea.yaml
ai_textarea:
  resource: '@AITextareaBundle/Resources/config/routes.yaml'
```

Configure the bundle:

```
# config/packages/ai_textarea.yaml
ai_textarea:
  api_key: '%env(AI_TEXTAREA_API_KEY)%'
  model: 'gpt-4o-mini'
```

Add your API key:

```
# .env.local
AI_TEXTAREA_API_KEY=sk-...
```

Publish assets (JS/CSS):

```
php bin/console assets:install --symlink --relative
# If symlinks don’t work (e.g., in multi-container Docker), run without --symlink:
# php bin/console assets:install
```

Usage
-----

[](#usage)

In a form type:

```
use RichBrains\AITextarea\Form\Type\AITextareaType;

$builder->add('content', AITextareaType::class, [
    'label' => 'Content',
    // Optional quick actions (shown as chips in the modal):
    'ai_actions' => ['friendly', 'professional', 'fix_grammar', 'shorter', 'longer'],
]);
```

What users see:

- A small AI button next to the textarea
- Modal with quick-action chips, custom prompt input, and result preview
- Copy the result or Replace the original textarea value

Options
-------

[](#options)

Global (config/packages/ai\_textarea.yaml):

- api\_key (string|null): Your OpenAI(-compatible) key
- model (string): Default gpt-4o-mini
- base\_url (string|null): Custom API base for compatible providers
- system\_prompt (string): System message for the assistant

```
$builder->add('content', AITextareaType::class, [
    'ai_actions' => ['fix_grammar', 'professional'],
]);
```

Customization
-------------

[](#customization)

Override Twig theme (optional):

1. Create templates/bundles/AITextareaBundle/form/ai\_textarea.html.twig
2. Copy the bundle’s template and modify it
3. If needed (when other configs override themes):

```
twig:
  form_themes:
    - '@AITextarea/form/ai_textarea.html.twig'
```

Tweak styles via CSS variables in ai-textarea.css:

```
:root {
  --ai-textarea-bg: #0b1020;
  --ai-textarea-surface: #131a2b;
  --ai-textarea-text: #e8eefc;
  --ai-textarea-accent: #4f8cff;
  /* ... */
}
```

Security &amp; Privacy
----------------------

[](#security--privacy)

- Enhance endpoint is CSRF-protected; ensure sessions are enabled
- Optionally restrict access (firewall/access\_control, voters)
- Text is sent to the AI provider; ensure user consent and data policy compliance

Troubleshooting
---------------

[](#troubleshooting)

Unknown function asset:

```
composer require symfony/asset
```

Ensure framework.assets: true and reinstall assets.

404 /bundles/aitextarea/ai-textarea.{js,css}:

- Run php bin/console assets:install (avoid --symlink in multi-container setups)
- Verify files exist under public/bundles/aitextarea/

No route for POST /\_ai\_textarea/enhance:

- Ensure routes are imported
- Check: php bin/console debug:router ai\_textarea\_enhance

403 Invalid CSRF token:

- Ensure same session, no full-page caching, CSRF enabled

Cannot autowire TextEnhancer $apiKey:

- Don’t auto-register the bundle classes via your app’s App: service resource
- Let the bundle’s services.yaml provide the scalar args

Using other OpenAI‑compatible providers
---------------------------------------

[](#using-other-openaicompatible-providers)

Set base\_url to the provider’s API root and pick the correct model. Example:

```
ai_textarea:
  api_key: '%env(AI_TEXTAREA_API_KEY)%'
  base_url: 'https://your-provider.example.com'
  model: 'gpt-4o-mini'   # or provider-specific model
```

How It Works
------------

[](#how-it-works)

- AITextareaType extends TextareaType, adding endpoint URL, CSRF token, and quick actions as data attributes
- Twig theme includes the bundle’s JS/CSS and initializes the UI
- Frontend modal collects text + instruction, POSTs to /\_ai\_textarea/enhance
- Controller calls TextEnhancer which uses HttpClient to call an OpenAI‑compatible chat completions API and returns the improved text

Changelog
---------

[](#changelog)

v0.1.0: Initial release with AITextareaType, modal UI, and OpenAI-compatible backend.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance62

Regular maintenance activity

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

239d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cd3150e78f5d4cc444870f9593231060649647c72031d695b8dc41b08592917a?d=identicon)[o-skaskevich](/maintainers/o-skaskevich)

---

Top Contributors

[![o-skaskevich](https://avatars.githubusercontent.com/u/48120192?v=4)](https://github.com/o-skaskevich "o-skaskevich (3 commits)")

---

Tags

aiphpsymfony-bundlesymfony-form

### Embed Badge

![Health badge](/badges/richbrains-ai-textarea/health.svg)

```
[![Health](https://phpackages.com/badges/richbrains-ai-textarea/health.svg)](https://phpackages.com/packages/richbrains-ai-textarea)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)[pentatrion/vite-bundle

Vite integration for your Symfony app

2725.3M13](/packages/pentatrion-vite-bundle)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)

PHPackages © 2026

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