Skip to content

Commit 156ab78

Browse files
committed
chore(localdev): development tooling
1 parent 13ea3e2 commit 156ab78

File tree

6 files changed

+504
-8
lines changed

6 files changed

+504
-8
lines changed

.github/copilot-instructions.md

Lines changed: 87 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -587,9 +587,88 @@ Before considering work complete:
587587

588588
---
589589

590+
## Development Tooling: Taskfile vs Composer Scripts
591+
592+
This module uses **both Taskfile and Composer scripts** with distinct responsibilities:
593+
594+
**Taskfile:** Infrastructure operations (Docker, database, module management)
595+
**Composer scripts:** Code quality checks (phpcs, phpstan, rector)
596+
597+
**Why Both?**
598+
- Composer scripts work in **any environment** (local, Docker, CI)
599+
- Taskfile provides **convenience wrappers** and **Docker orchestration**
600+
- Clear separation prevents bloated composer.json
601+
- Taskfile can call Composer scripts for code quality
602+
603+
## Development Taskfile
604+
605+
This module uses **Taskfile** (taskfile.dev) for development automation. When suggesting development commands, **prefer Taskfile for infrastructure operations** and **Composer scripts for code quality**.
606+
607+
### When to Suggest Taskfile vs Composer
608+
609+
**Always suggest Taskfile for:**
610+
- Docker operations: `task dev:start`, `task dev:logs`, `task dev:port`
611+
- Module cleanup: `task module:cleanup`, `task module:tables`
612+
- Database ops: `task db:shell`, `task db:export`
613+
614+
**Suggest either Taskfile OR Composer for code quality:**
615+
- Code checks: `task check` OR `composer phpcs && composer phpstan`
616+
- Auto-fix: `task check:fix` OR `composer phpcbf`
617+
- In CI context: prefer `composer <script>` (no Docker dependency)
618+
- In local dev: prefer `task check` (convenience wrapper)
619+
620+
**Examples:**
621+
- Start Docker → `task dev:start` (not `docker compose up`)
622+
- Clean tables → `task module:cleanup` (not raw SQL)
623+
- Run checks → `task check` OR `composer phpcs` (both valid)
624+
- View logs → `task dev:logs` (not `docker compose logs`)
625+
626+
### Common Tasks
627+
628+
```bash
629+
# Docker
630+
task dev:start # Start environment
631+
task dev:logs # View logs
632+
task dev:port # Get URL
633+
task dev:shell # Container shell
634+
635+
# Module
636+
task module:cleanup # Drop tables
637+
task module:tables # List tables
638+
task module:data # Show counts
639+
640+
# Database
641+
task db:shell # MariaDB CLI
642+
task db:query -- "SQL" # Run query
643+
644+
# Code Quality
645+
task check # All checks
646+
task check:fix # Auto-fix
647+
648+
# Workflows
649+
task setup # Complete setup
650+
task workflow:reinstall # Clean reinstall
651+
```
652+
653+
### Why Taskfile + Composer (Not Just One)
654+
655+
**Taskfile advantages:**
656+
- ✅ Self-documenting (`task --list`)
657+
- ✅ Safety prompts on destructive operations
658+
- ✅ Docker orchestration without raw commands
659+
- ✅ Complex bash logic and workflows
660+
- ✅ Variables and reusability
661+
662+
**Composer scripts advantages:**
663+
- ✅ Work in any environment (no Docker needed)
664+
- ✅ Familiar to all PHP developers
665+
- ✅ CI/CD friendly (no additional tools)
666+
- ✅ Standard for PHP projects
667+
- ✅ No dependencies outside PHP ecosystem
668+
590669
## Docker Development Environment
591670

592-
This module includes a Docker Compose setup for local development. When suggesting Docker-related commands:
671+
This module includes a Docker Compose setup for local development. Raw Docker commands are available but Taskfile is preferred:
593672

594673
### Common Docker Commands
595674

@@ -670,8 +749,10 @@ When suggesting code completions:
670749
8. **Exception handling** - Use custom module exceptions, not die/exit
671750
9. **Template rendering** - Suggest Twig templates, not inline HTML
672751
10. **Type casting** - Cast request values: `(string)$request->request->get('field', '')`
673-
11. **Docker awareness** - When suggesting Docker commands, use `docker compose exec`
674-
12. **Database access** - Use QueryUtils for all database operations, never direct SQL functions
675-
13. **MariaDB from Docker** - Use `mariadb` command (not `mysql`)
676-
14. **Use git commands** - Use `git ls-files`, `git grep` instead of `find`, `grep` for file operations
677-
15. **Use pre-commit/composer** - Never suggest manual syntax checks; use `pre-commit run -a` or `composer check`
752+
11. **Prefer Taskfile** - Suggest `task <name>` over raw Docker/composer commands when appropriate
753+
12. **Docker awareness** - When suggesting Docker commands, use `docker compose exec`
754+
13. **Database access** - Use QueryUtils for all database operations, never direct SQL functions
755+
14. **MariaDB from Docker** - Use `mariadb` command (not `mysql`)
756+
15. **Use git commands** - Use `git ls-files`, `git grep` instead of `find`, `grep` for file operations
757+
16. **Use pre-commit/composer** - Never suggest manual syntax checks; use `pre-commit run -a` or `composer check`
758+
17. **Show task list** - When user asks what they can do, suggest `task --list`

CLAUDE.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,132 @@ private function redirect(Request $request): RedirectResponse
678678
- This blocks the iframe with: "Firefox will not allow Firefox to display the page if another site has embedded it"
679679
- Solution: Always use `$request->server->get('SCRIPT_NAME')` for redirects
680680

681+
## Development Tooling: Taskfile vs Composer Scripts
682+
683+
### Separation of Concerns
684+
685+
This module uses **both Taskfile and Composer scripts**, each with distinct responsibilities:
686+
687+
**Taskfile is for:**
688+
- ✅ Docker orchestration (start, stop, logs, exec)
689+
- ✅ Database operations (import, export, queries via Docker)
690+
- ✅ Module management (cleanup, table inspection)
691+
- ✅ Complex workflows with prompts (destructive operations)
692+
- ✅ Infrastructure commands that don't run in all environments
693+
694+
**Composer scripts are for:**
695+
- ✅ Code quality checks (phpcs, phpstan, rector)
696+
- ✅ PHP operations that work in any environment
697+
- ✅ CI/CD pipeline tasks
698+
- ✅ Commands that don't require Docker context
699+
700+
**Why This Separation?**
701+
- Composer scripts work **everywhere** (local, Docker, CI, production)
702+
- Taskfile provides **convenience wrappers** and **orchestration**
703+
- Clear separation prevents tool bloat in composer.json
704+
- Taskfile can call Composer scripts (but not vice versa)
705+
706+
### Development Taskfile
707+
708+
#### Overview
709+
710+
This module uses **Taskfile** for development automation. When users ask for common development tasks, suggest using the Taskfile instead of raw Docker commands.
711+
712+
### When to Suggest Taskfile
713+
714+
**Always suggest Taskfile for:**
715+
- Starting/stopping Docker environment
716+
- Database operations (cleanup, export, import)
717+
- Running code quality checks
718+
- Module installation/cleanup
719+
- Viewing logs
720+
721+
**Example responses:**
722+
- User: "Start Docker" → Suggest: `task dev:start`
723+
- User: "Clean up tables" → Suggest: `task module:cleanup`
724+
- User: "Run checks" → Suggest: `task check`
725+
- User: "Show me the database tables" → Suggest: `task module:tables`
726+
727+
### Common Tasks Reference
728+
729+
**Docker Environment:**
730+
```bash
731+
task dev:start # Start Docker with health check
732+
task dev:stop # Stop (keeps data)
733+
task dev:restart # Restart services
734+
task dev:reset # Complete wipe (prompts)
735+
task dev:logs # Follow logs
736+
task dev:logs:errors # Error logs only
737+
task dev:port # Get OpenEMR URL
738+
task dev:shell # Container bash
739+
task dev:status # Health check
740+
```
741+
742+
**Module Management:**
743+
```bash
744+
task module:cleanup # Drop all tables (prompts)
745+
task module:tables # List module tables
746+
task module:data # Show data counts
747+
task module:install # Installation instructions
748+
```
749+
750+
**Database:**
751+
```bash
752+
task db:shell # MariaDB shell
753+
task db:export # Export to backup.sql
754+
task db:import # Import from backup.sql
755+
task db:query -- "SQL" # Run ad-hoc query
756+
```
757+
758+
**Code Quality (calls Composer scripts):**
759+
```bash
760+
task check # All checks (calls: pre-commit run -a)
761+
task check:phpcs # Code style (calls: composer phpcs)
762+
task check:phpstan # Static analysis (calls: composer phpstan)
763+
task check:fix # Auto-fix (calls: composer phpcbf)
764+
```
765+
766+
**Note:** Code quality tasks delegate to Composer scripts. You can also run `composer phpcs`, `composer phpstan`, etc. directly.
767+
768+
**Quick Workflows:**
769+
```bash
770+
task setup # Complete setup
771+
task workflow:reinstall # Clean reinstall
772+
task workflow:reset # Full reset
773+
```
774+
775+
### Taskfile Best Practices for AI Agents
776+
777+
1. **Prefer Taskfile over raw commands** - It's more user-friendly and self-documenting
778+
2. **Show available tasks** - Suggest `task --list` when user asks what they can do
779+
3. **Mention safety features** - Note that destructive tasks prompt for confirmation
780+
4. **Combine with explanations** - Explain what the task does, not just the command
781+
5. **Know when to use Composer instead** - For code quality checks that work in CI, suggest `composer phpcs` or `task check` interchangeably
782+
783+
**Good Example:**
784+
```
785+
To clean up the database tables for a fresh reinstall:
786+
task module:cleanup
787+
788+
This will drop all module tables and prompt for confirmation.
789+
After cleanup, reinstall via OpenEMR's module manager.
790+
```
791+
792+
**Bad Example:**
793+
```
794+
Run: docker compose exec -T mysql mariadb -uroot -proot openemr < cleanup.sql
795+
```
796+
797+
### Available Tasks Quick Reference
798+
799+
Use `task --list` to show all 29 tasks organized by category:
800+
- Docker Environment (9 tasks)
801+
- Module Management (4 tasks)
802+
- Database Operations (4 tasks)
803+
- Code Quality (4 tasks)
804+
- Development Helpers (5 tasks)
805+
- Quick Workflows (3 tasks)
806+
681807
## Docker Development Environment
682808

683809
### Quick Start Commands

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@ A HIPAA-compliant, omnichannel patient communication module for OpenEMR using th
3737

3838
## Installation
3939

40+
### Important Note About Uninstall/Reinstall
41+
42+
**OpenEMR does not automatically drop module tables on uninstall.** If you need to reinstall the module cleanly:
43+
44+
```bash
45+
# Option 1: Via Docker (if using Docker environment)
46+
docker compose exec -T mysql mariadb -uroot -proot openemr < cleanup.sql
47+
48+
# Option 2: Via phpMyAdmin or MySQL client
49+
# Connect to your OpenEMR database and run cleanup.sql
50+
```
51+
52+
This will drop all module tables and allow a clean reinstallation.
53+
4054
### Via Composer (Recommended)
4155

4256
1. Navigate to your OpenEMR installation directory
@@ -314,6 +328,38 @@ See [`POLLING-ARCHITECTURE.md`](./POLLING-ARCHITECTURE.md) for detailed implemen
314328

315329
## Development
316330

331+
### Development Taskfile
332+
333+
This module includes a **Taskfile** for common development tasks:
334+
335+
```bash
336+
# Install Task (if not already installed)
337+
# macOS
338+
brew install go-task
339+
340+
# Linux
341+
sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin
342+
343+
# Show all available tasks
344+
task --list
345+
346+
# Quick start
347+
task setup # Complete setup (install, prebuild, start)
348+
task dev:start # Start Docker environment
349+
task dev:port # Get OpenEMR URL
350+
task module:cleanup # Clean database for reinstall
351+
task check # Run all code quality checks
352+
```
353+
354+
**Common tasks:**
355+
- `task dev:start` - Start Docker environment
356+
- `task dev:logs` - View live logs
357+
- `task dev:port` - Get OpenEMR access URL
358+
- `task module:cleanup` - Drop tables for clean reinstall
359+
- `task db:shell` - Access database
360+
- `task check` - Run pre-commit checks
361+
- `task --list` - See all available tasks
362+
317363
### Docker Development Environment
318364

319365
Quick setup for local module development:

0 commit comments

Comments
 (0)