|
| 1 | +# Development Guide for `laravel-route-docs` |
| 2 | + |
| 3 | +This document outlines the local development workflow for building and testing the `laravel-route-docs` package, |
| 4 | +as well as integrating it into other Laravel projects before publishing. |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## Project Setup |
| 9 | + |
| 10 | + - [Docker](https://www.docker.com/) |
| 11 | + - [Taskfile](https://taskfile.dev/) |
| 12 | + |
| 13 | +### Setup & Install Dependencies |
| 14 | + |
| 15 | +```bash |
| 16 | +task build |
| 17 | +``` |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Running Tests |
| 22 | + |
| 23 | +### PHPUnit |
| 24 | + |
| 25 | +```bash |
| 26 | +task test:unit |
| 27 | +``` |
| 28 | + |
| 29 | +Or run tests against all versions of PHP: |
| 30 | + |
| 31 | +```bash |
| 32 | +task test:all |
| 33 | +``` |
| 34 | + |
| 35 | +--- |
| 36 | + |
| 37 | +## Route Integration Tests with Laravel Kernel |
| 38 | + |
| 39 | +- Tests extend `Tests\TestCase`, which boots a full Laravel app kernel using Testbench. |
| 40 | +- Example route definitions are injected using `defineRoutes()`. |
| 41 | + |
| 42 | +--- |
| 43 | + |
| 44 | +## Using This Package in Another Laravel Project (During Development) |
| 45 | + |
| 46 | +If you're actively developing this package and want to test it **in another Laravel app** without publishing it yet: |
| 47 | + |
| 48 | +### Option 1: Path Repository (Recommended) |
| 49 | + |
| 50 | +In your consuming Laravel app's `composer.json`: |
| 51 | + |
| 52 | +```json |
| 53 | +"repositories": [ |
| 54 | + { |
| 55 | + "type": "path", |
| 56 | + "url": "../path-to/laravel-route-docs" |
| 57 | + } |
| 58 | +], |
| 59 | +"require": { |
| 60 | + "mikegarde/laravel-route-docs": "*" |
| 61 | +} |
| 62 | +``` |
| 63 | + |
| 64 | +Then run: |
| 65 | + |
| 66 | +```bash |
| 67 | +composer update mikegarde/laravel-route-docs |
| 68 | +``` |
| 69 | + |
| 70 | +> Changes in `laravel-route-docs` will be picked up live, no commit/push needed. |
| 71 | +
|
| 72 | +--- |
| 73 | + |
| 74 | +## Using Inside Docker (Path Setup) |
| 75 | + |
| 76 | +If you're using Docker and the package is **outside** the app folder, mount both volumes in your `docker-compose.yml`: |
| 77 | + |
| 78 | +```yaml |
| 79 | +services: |
| 80 | + php: |
| 81 | + volumes: |
| 82 | + - ../your-laravel-app:/var/www/html |
| 83 | + - ../laravel-route-docs:/packages/laravel-route-docs |
| 84 | +``` |
| 85 | +
|
| 86 | +Then in the app's `composer.json`: |
| 87 | + |
| 88 | +```json |
| 89 | +"repositories": [ |
| 90 | + { |
| 91 | + "type": "path", |
| 92 | + "url": "/packages/laravel-route-docs" |
| 93 | + } |
| 94 | +] |
| 95 | +``` |
| 96 | + |
| 97 | +Run this inside your container: |
| 98 | + |
| 99 | +```bash |
| 100 | +composer require mikegarde/laravel-route-docs:* --prefer-source |
| 101 | +# And maybe also: |
| 102 | +composer dump-autoload |
| 103 | +php artisan ide-helper:generate |
| 104 | +``` |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +## Helpers and Polyfills |
| 109 | + |
| 110 | +To support `base_path()` and `app_path()` in both Laravel and standalone mode: |
| 111 | +- Polyfills are provided in `src/helpers.php`. |
| 112 | +- Registered in `composer.json` under `autoload.files`. |
| 113 | + |
| 114 | +--- |
| 115 | + |
| 116 | +## Useful Commands |
| 117 | + |
| 118 | +- `php artisan route:docs` — show documented routes |
| 119 | +- `php artisan route:docs:validate` — validate attribute/route consistency |
| 120 | +- `composer test` — run all tests |
| 121 | + |
| 122 | +--- |
| 123 | + |
| 124 | +## Notes |
| 125 | + |
| 126 | +- The `examples/Http/Controllers` folder contains real attribute usage for demo and test purposes. |
| 127 | + |
0 commit comments