Skip to content

Refactor: split monolithic index.php into src/, views/, and README#1

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/refactor-repo-directory-structure
Draft

Refactor: split monolithic index.php into src/, views/, and README#1
Copilot wants to merge 2 commits intomainfrom
copilot/refactor-repo-directory-structure

Conversation

Copy link

Copilot AI commented Mar 3, 2026

The entire application lived in a single 700-line index.php with no separation of concerns — config, DB bootstrapping, request handling, and HTML rendering all interleaved.

New structure

pastebin/
├── index.php            # Entry point: session start + 4 requires (~23 lines)
├── src/
│   ├── config.php       # DB credentials + all app constants
│   ├── db.php           # PDO bootstrap, DB/table auto-creation
│   ├── helpers.php      # Pure functions, $languages map, $basePath
│   └── handlers.php     # All POST/GET handlers; sets view variables
├── views/
│   ├── layout.php       # HTML shell, global JS
│   ├── paste.php        # Code block, comments, delete form + paste JS
│   ├── create.php       # Create form
│   └── sidebar.php      # Recent pastes
└── README.md

Key points

  • Zero functional changes — identical behavior, SQL, cookie/session logic, and rendered HTML
  • Each file has a single responsibility; variables flow via PHP's include scope ($paste, $comments, $recentPastes, $basePath, $languages set before views are included)
  • src/config.php is the single place to touch for deployment configuration
  • README.md covers directory layout, all configurable constants, installation steps, usage, and a production checklist

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: druvx13 <131332414+druvx13@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor repository for better directory organization and documentation Refactor: split monolithic index.php into src/, views/, and README Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants