# Add User Registration to a Symfony App from a Linear Issue

Yes. An agent reads the Linear issue, adds a registration form and controller that fit your Symfony security setup, tests them with PHPUnit and opens a pull request.

[Run this on Rush](https://cloud.getrush.ai/run/add-user-registration/symfony/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent starts from the issue and the repository in its own cloud sandbox and reads the security setup before it writes a form. In an app like symfony/demo (Symfony `^8` on PHP `>=8.4`, Doctrine ORM `^3.5`), `config/packages/security.yaml` loads users from the `App\Entity\User` entity by `username`, uses the `auto` password hasher, and configures `form_login` on the `security_login` route with CSRF, `remember_me` for a week and a `logout` target; under `when@test` it switches the firewall to `http_basic` and lowers the hasher cost. `src/Entity/User.php` maps `symfony_demo_user` with `fullName` (`NotBlank`), `username` (`NotBlank`, `Length(min: 2, max: 50)`, unique), `email` (`Email`, unique), `password` and a JSON `roles` column with `ROLE_USER` and `ROLE_ADMIN` constants. There is a `/login` page in `SecurityController` and a `/profile/edit` and `/profile/change-password` pair in `UserController` behind `IsGranted(User::ROLE_USER)`, but no route that creates an account: users come from `src/DataFixtures/AppFixtures.php` or the `app:add-user` console command.

That command is where the project's rules for a new user already live, and the agent reuses them rather than inventing new ones. `src/Command/AddUserCommand.php` validates through `src/Utils/Validator.php`: a username of lowercase latin letters and underscores, a password of at least six characters, an email with an `@`, a non-empty full name, and hashes the password with `UserPasswordHasherInterface`. The forms in `src/Form/` show the house style: `UserType` with `label.username`, `label.fullname` and `label.email` translation keys, and `ChangePasswordType` with a `RepeatedType` for the new password. Routes are prefixed with `/{_locale}` from `config/routes.yaml`, so the new page is `/en/register`, and every label goes through `translations/messages+intl-icu.<locale>.xlf`.

The change lands in the files that own it. A `RegistrationType` form in `src/Form/` with `username`, `fullName`, `email` and an unmapped `plainPassword` `RepeatedType`, carrying the same length and format rules the command enforces. `UniqueEntity` constraints on `username` and `email` in `User.php`, so a duplicate shows a form error instead of a database exception. A `RegistrationController` with a `/register` route named `user_register` that redirects a signed-in user to `blog_index` the way `SecurityController::login` does, hashes the password, sets `roles` to `[User::ROLE_USER]`, persists the user and logs them in through the `Security` service so they land on the blog already authenticated. A `templates/user/register.html.twig` built like `edit.html.twig` with `form_start`, `form_widget` and a `twig:ux:icon` button, a link from the login form's sidebar, and new keys such as `title.register` and `action.register` added to the English catalogue so the other locales fall back to it.

Last, it tests the way the project does. `tests/Controller/UserControllerTest.php` extends `WebTestCase`, uses a `DataProvider` for anonymous URLs and asserts a redirect to `http://localhost/en/login`; `DefaultControllerTest::testPublicUrls` lists pages that must answer 200. The agent adds `tests/Controller/RegistrationControllerTest.php`: `/en/register` is public, a valid submission creates a user in the SQLite database from `.env.test` and redirects, a taken username and a mismatched password repeat show errors, and a logged-in user is redirected away. It runs `vendor/bin/phpunit`, whose `phpunit.dist.xml` fails on any deprecation, notice or warning, then `vendor/bin/phpstan` and `php-cs-fixer` from the dev dependencies, and pushes once all three are clean on PHP 8.4, the version `.github/workflows/tests.yaml` runs alongside 8.5.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "A Linear issue labeled agent says: \"Visitors cannot create an account. Add a registration page with username, full name, email and password (entered twice), log the new user in on success, and link to it from the login page.\" Before changing anything, read config/packages/security.yaml, the User entity, the forms under src/Form, the add-user console command and its validator, the login template, and the translation files, and say what rules for a new user already exist. Reuse those rules: build a registration form type that enforces the same username, password, email and full-name constraints, add UniqueEntity constraints for username and email, add a controller route under the locale prefix that hashes the password with the configured hasher, assigns ROLE_USER, persists the user and logs them in, and a template in the project's form style with translated labels added to the English catalogue. Redirect already-authenticated users away. Add a WebTestCase covering the public page, a successful registration, a duplicate username, a password mismatch and the redirect for signed-in users. Run vendor/bin/phpunit, phpstan and php-cs-fixer until they pass, then open a pull request that links back to the issue.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request on its own branch whose description starts with what the agent found: that the app had a login page, a profile editor and a console command for creating users, but no registration route, and that the validation rules it reused came from `src/Utils/Validator.php` and the entity constraints. The diff adds `RegistrationType`, `RegistrationController`, `register.html.twig`, the `UniqueEntity` constraints, the English translation keys, the login-page link and the new test class.

The transcript carries the proof: each `vendor/bin/phpunit` run with its output, including any that failed before a fix, and the `phpstan` and `php-cs-fixer` runs. If the repository's test workflow runs on pull requests, it runs there too on the PHP versions it declares, so the reviewer sees the suite pass on GitHub as well.

Before merging, a reviewer checks that the password rules match what the issue and the console command expect, that the `UniqueEntity` messages are translated, that a registration does not grant `ROLE_ADMIN` under any input, that the CSRF token is on the form, and that the automatic login uses the same firewall as the login page so `remember_me` behaves the same way.

## Run it on every Linear issue labelled agent

In the console, an automation with a `linear` trigger on `linear.issue.labeled` and the label `agent` starts one run per labelled issue in the Project's repository. The trigger adds the issue's text after the saved prompt, so the fields the form needs and the wording of the page come from the issue. Changes made by an app integration never fire it, and the automation's `max_runs_per_hour` bounds how many runs a burst of labelling can start.

From your own server, the same job is one `POST /o/{org}/sessions` per issue, with the repository in `resources` and the issue's `https://linear.app/<workspace>/issue/<ID>` URL beside it so Rush reads the issue through your Linear connection. A `webhook_url` on the API key receives `run.completed` or `run.failed` for every run that key starts, with the `session_url` to read the pull request link from.

## Why run it on Rush?

A registration page touches security configuration, the entity, a form, a template and translations, and the only honest check is the functional suite against a real database. In a Rush sandbox the agent installs Composer dependencies, lets the project's `auto-scripts` build assets and the SQLite database, and runs PHPUnit, PHPStan and the code-style fixer as many times as it takes, without a PHP toolchain on anyone's laptop.

A label in Linear becomes a reviewable pull request with its reasoning on the record: the transcript shows the agent reading `security.yaml`, the entity and the console command before it writes, and every test run with its output. Several labelled issues can run at once, each in its own sandbox on its own branch, and each pull request links back to the issue that asked for it.

## Frequently asked questions

### Will it change the login page or the existing users?

The login form stays as it is apart from a link to the new page. Existing users and the fixtures are untouched; the new `UniqueEntity` constraints only add form-level errors for values the database already refuses.

### Does the new user get logged in automatically?

Yes, through the `Security` service's login on the `main` firewall, the same one the login form uses, so the session and `remember_me` behave the way they do after a manual login. The test asserts the redirect and that a following request is authenticated.

### Which validation rules does it apply to the password and username?

The ones the project already has: the username format and the six-character password minimum from `src/Utils/Validator.php`, plus the `Length` and `Email` constraints on the entity. If the issue asks for stricter rules, the agent adds them to the form type and says so in the pull request.

### Does it need a database migration?

Not for the fields the issue names, because `username`, `email`, `fullName` and `password` already exist on the entity. If the issue adds a field such as an accepted-terms timestamp, the agent adds it to the entity and generates a migration, and the pull request calls that out.

### Will email verification be included?

Not unless the issue asks for it. The project has `symfony/mailer` configured, so a verification email is a reasonable follow-up, and the pull request notes that the controller is written so a verification step can be inserted before the automatic login.

## More Symfony jobs

- [Dockerize a Symfony App](https://getrush.ai/run/dockerize-app/symfony/)
- [Fix Failing GitHub Actions Checks in a Symfony App](https://getrush.ai/run/fix-failing-ci/symfony/)
- [Fix N+1 Queries in a Symfony App](https://getrush.ai/run/fix-n-plus-one-queries/symfony/)

## The same job on other stacks

- [Add User Registration to a Vapor App](https://getrush.ai/run/add-user-registration/vapor/)
- [Add User Registration to a CodeIgniter App](https://getrush.ai/run/add-user-registration/codeigniter/)
- [Add User Registration to a Fastify App](https://getrush.ai/run/add-user-registration/fastify/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
