Repository navigation
Open
Description
Goal
- Produce a complete, reviewable mapping of the existing PHP project to support creating a new monorepo with:
- Backend: C# / .NET (ASP.NET Core)
- Frontend: Angular
- Database: keep MySQL for now (no migration required yet)
- Output MUST be committed in a branch and opened as a pull request that contains:
- docs/scan-summary.md (high-level summary and findings)
- docs/api-endpoints.md (complete list of backend API endpoints with details)
- docs/frontend-pages.md (complete list of frontend pages/views with behaviour)
- migration-issues/ (one markdown file per endpoint/page with a ready-to-create issue template for the new monorepo)
- Optionally: artifacts/regex-results.txt (raw grep output) to aid reviewer debugging
Context and permissions
- You run inside this repository and have read access to all files.
- Create a new branch named
migration/scan-mapping(or similar) and commit the outputs to that branch, then open a pull request against the repository's default branch. - If asked later, produce draft issues for a target repository (the new monorepo) in a format that can be fed to an issue-creation tool (title, body, labels, suggested assignees, estimate).
Workplan / Steps (execute these)
-
Create branch:
- git checkout -b migration/scan-mapping
-
Source discovery (run programmatic scans; include raw outputs as artifact)
- Run these searches (capture outputs to artifacts/regex-results.txt):
- rg --hidden -n --no-ignore-vcs "json_encode|echo json_encode|header(.*application/json|wp_ajax|wp_ajax_nopriv|route|Router::|Flight::route|Slim\|$this->router->|Laravel\|Route::|Symfony\|$app->get|$app->post" || true
- rg --hidden -n --no-ignore-vcs "(GET|POST|PUT|DELETE|PATCH):|\$_GET|\$_POST|\$_REQUEST|file_get_contents\(|curl_exec\(|http_response_code\(" || true
- rg --hidden -n --no-ignore-vcs "function [a-zA-Z0-9_]+Action|class .*Controller|Controller extends|routes.php|index.php|.htaccess" || true
- rg --hidden -n --no-ignore-vcs "form|input|name=|action=|method=post|<form" || true
- rg --hidden -n --no-ignore-vcs "SELECT .* FROM|INSERT INTO|UPDATE .* SET|DELETE FROM|->query\(|pdo->prepare" || true
- Save the exact command outputs as artifacts/regex-results.txt
- Run these searches (capture outputs to artifacts/regex-results.txt):
-
Programmatic parsing heuristics (extract endpoints and pages)
-
Identify entry points: index.php, public/ or webroot files, routing config (routes.php, router classes, frameworks like Laravel/Slim/Symfony).
-
For each discovered route:
- Determine HTTP method, path, handler (file + function + class), whether returns JSON or HTML, auth requirements (session checks, auth middleware).
- Find referenced DB tables and example SQL queries in same handler.
- Extract sample request params and response format (if JSON responses, include example outputs or construct one).
- Record any input validation and expected status codes.
- If handler calls other internal functions or includes templates, link to those files.
-
For frontend views / pages:
- Identify templates (PHP views, Twig, Blade, plain HTML/PHP).
- For each page, record route/URL, template file(s), main UI elements (forms, file uploads, tables, modals), JS files used, AJAX calls (endpoints + payload shapes), and browser features relied on.
- If pages call endpoints via fetch/XHR, capture the exact request shape (headers, body). Include examples of JS functions or jQuery calls.
-
-
Database references
- Map DB tables referenced by name to handler(s).
- Record any migrations or schema hints (CREATE TABLE, commented schemas in SQL).
- Produce a table list and for each table include columns found in queries (approximate schema).
-
Output format (strict)
- docs/scan-summary.md
- Project quick stats (size, number of PHP files scanned, number of discovered endpoints, pages)
- Important notes (auth type, external APIs, background jobs, cron, session usage, file uploads)
- Top 10 risky/complex areas to prioritize in migration
- docs/api-endpoints.md
- For each endpoint include:
- ID: incremental identifier (e.g., API-001)
- Path: (e.g., /api/upload)
- Method: GET/POST/PUT/DELETE
- Returns: JSON/HTML/file/redirect
- Auth: none / session / API token / role-based
- Handler: path/to/file.php::Class::method or path/to/file.php::function
- Code excerpt: include the smallest viable code sample (8–20 lines) that shows routing and handling
- Params: list of expected request parameters (name, type if known, required/optional)
- Response example: JSON or HTML snippet
- DB tables used: []
- External services: []
- Tests to add: minimal integration test description and acceptance criteria
- Priority: P0/P1/P2 (heuristic: anything breaking existing production flows = P0)
- For each endpoint include:
- docs/frontend-pages.md
- For each page include:
- ID: PAGE-001
- Route/URL
- Template(s): file paths
- Visible features: forms, lists, paginations, file uploads, complex JS widgets
- Data sources: which API endpoints feed this page
- Interactions: create/update/delete flows, inline editing, validations
- Auth requirement
- Suggested Angular mapping: component name, route path, services needed, state management hint (store/ngrx if complex)
- Acceptance criteria for recreated page
- For each page include:
- migration-issues/
- For every API endpoint and page, create a one-file-per-item issue draft:
- Filename: migration-issues/API-001--post-upload.md or migration-issues/PAGE-001--user-list.md
- Content must be a ready-to-create issue using the issue template below (Title, Body, Labels, Suggested Assignees, Estimate)
- Body must include links to source file locations and relevant code excerpts.
- For every API endpoint and page, create a one-file-per-item issue draft:
- docs/scan-summary.md
-
Issue template content (for each file in migration-issues/)
- Title: Migrate API: POST /upload -> POST /api/uploads (API-001)
- Body sections:
- Summary
- Source references
- Behavior to match (inputs, responses, side effects)
- Acceptance criteria (explicit tests)
- Suggested .NET endpoints, controller name, DTOs, sample C# signature
- Suggested Angular component/service names and route
- DB table mapping and sample queries or ORM notes
- Complexity estimate (T-shirt or story points)
- Labels: migration, backend, frontend (if frontend also required), priority/P0/P1
- Include code excerpts as fenced blocks.
-
Quality and verification
- Each endpoint and page entry must reference exact file paths and line numbers (where possible) and include at least one code excerpt.
- Validate that every AJAX or JSON endpoint referenced from JS files appears in the api-endpoints.md (cross-check).
- Ensure no duplicate entries; unify duplicates and note aliases/legacy routes.
-
Commit & PR
- Commit the docs and artifacts on branch migration/scan-mapping with a clear commit message: "chore(migration): initial repository scan and mapping for .NET + Angular migration"
- Open a pull request titled: "Migration: initial repo scan & mapping (API + frontend)". PR body should summarize generated files and next recommended steps.
- Add reviewers: @MadsThy and @repo-maintainers (if available).
Search commands and parsing hints (copy/paste)
- ripgrep (rg) commands already listed above.
- To capture PHP functions and controllers:
- rg --hidden -n "class .*Controller|function .*Action|function [a-zA-Z0-9_]+\(" --glob '!vendor' || true
- To find ajax/json:
- rg --hidden -n "fetch\(|\.ajax\(|XMLHttpRequest|axios\.post|axios\.get|json_encode|echo json_encode" || true
Formatting examples (strict templates)
- API item example (markdown snippet to be included in docs/api-endpoints.md):
ID: API-001
Path: POST /upload
Method: POST
Returns: JSON { id, url }
Auth: session (checks $_SESSION['user_id'])
Handler: src/handlers/upload.php::handle_upload()
Code excerpt:
```php
<?php
// src/handlers/upload.php
function handle_upload() {
if (!isset($_SESSION['user_id'])) { http_response_code(401); echo json_encode(['error'=>'unauth']); return; }
...
}
Params:
- file (multipart/form-data) required
Response example:
{ "id": 123, "url": "/uploads/123.zip" }
DB tables: uploads (insert)
External services: none
Tests to add: - Integration test: POST multipart with 6MB file -> 200 and JSON with url; unit test for validation error (no file).
Priority: P1
- Page item example (markdown snippet for docs/frontend-pages.md):
ID: PAGE-001
Route: /users/list.php (friendly URL: /users)
Template: views/users/list.php
Features:
- paginated user table
- search filter (name/email)
- inline role change (AJAX POST /api/users/{id}/role)
Data sources: - GET /api/users?page=1&search=...
Interactions: - click Save on role -> POST /api/users/{id}/role { role: "admin" }
Suggested Angular mapping: - Component: users/list.component.ts
- Service: users.service.ts
Acceptance criteria: - Component displays paginated list, search works, inline role change updates UI and persists.
Acceptance for the overall task
- PR contains the four main files + migration-issues/ files.
- Every entry in docs/api-endpoints.md and docs/frontend-pages.md has at least: path/route, handler/template, code excerpt, and acceptance criteria.
- Cross-check completeness: number of AJAX endpoints referenced in JS == number of entries in api-endpoints.md (or list mismatches if any).
If you lack confidence about a route/handler link, mark it as "uncertain" with a short note and include the candidate file paths.
What I expect you to produce in this PR (deliverables)
- docs/scan-summary.md
- docs/api-endpoints.md
- docs/frontend-pages.md
- migration-issues/*.md (one file per endpoint/page)
- artifacts/regex-results.txt (raw grep output)
- A PR created on branch migration/scan-mapping with a descriptive title and body
Tone and style
- Use concise, actionable language. Present code excerpts and file links. Keep each entry machine- and human-readable.
If you need additional privileges (e.g., to open a PR or create issues in another repository), report exactly which action failed and the exact error output; do not proceed with destructive changes.
End of agent prompt.
Reacted by Copilot
Metadata
Metadata
Assignees
Labels
No labels
Activity