|
1 | 1 | [](LICENSE) [](https://github.com/impresscms-dev/generate-php-project-classes-list-file-action/releases) |
2 | 2 |
|
3 | | -# Generate PHP project classes list file action |
| 3 | +# Generate PHP Project Classes List File Action |
4 | 4 |
|
5 | | -GitHub action to generate a file with [PHP](https://php.net) project classes list (works only with [composer](https://getcomposer.org) projects). Built with Node.js 20. |
| 5 | +A GitHub Action that generates a comprehensive list of classes in your [PHP](https://php.net) project. This action is designed to work with projects that use [Composer](https://getcomposer.org) for dependency management. |
6 | 6 |
|
7 | 7 | ## Usage |
8 | 8 |
|
9 | | -To use this action in your project, create workflow in your project similar to this code (Note: some parts and arguments needs to be altered): |
| 9 | +To integrate this action into your project, create a GitHub workflow file similar to the example below. You can customize the configuration to match your project's specific requirements: |
10 | 10 | ```yaml |
11 | | -name: Generate PHP project class list as artifact |
| 11 | +name: Generate PHP Class List |
12 | 12 |
|
13 | 13 | on: |
14 | 14 | push: |
| 15 | + branches: [main] |
15 | 16 |
|
16 | 17 | jobs: |
17 | | - get_php_classes_list: |
| 18 | + generate-class-list: |
18 | 19 | runs-on: ubuntu-latest |
19 | 20 | steps: |
20 | | - - name: Checkouting project code... |
| 21 | + - name: Checkout repository |
21 | 22 | uses: actions/checkout@v4 |
22 | 23 |
|
23 | | - - name: Install PHP |
24 | | - uses: shivammathur/setup-php@master |
| 24 | + - name: Setup PHP environment |
| 25 | + uses: shivammathur/setup-php@v2 |
25 | 26 | with: |
26 | 27 | php-version: 8.4 |
27 | 28 | extensions: curl, gd, pdo_mysql, json, mbstring, pcre, session |
28 | 29 | ini-values: post_max_size=256M |
29 | 30 | coverage: none |
30 | 31 | tools: composer:v2 |
31 | 32 |
|
32 | | - - name: Install Composer dependencies (with dev) |
33 | | - run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader |
| 33 | + - name: Install Composer dependencies |
| 34 | + run: composer install --no-progress --prefer-dist --optimize-autoloader |
34 | 35 |
|
35 | | - - name: Getting PHP classes list... |
| 36 | + - name: Generate PHP classes list |
36 | 37 | uses: impresscms-dev/generate-php-project-classes-list-file-action@v2 |
37 | 38 | with: |
38 | 39 | output_file: ./php-classes.lst |
39 | 40 | # Optional: specify a different path if composer.json is not in the root |
40 | 41 | # project_path: ./src |
41 | 42 |
|
42 | | - - uses: actions/upload-artifact@v4 |
| 43 | + - name: Upload classes list as artifact |
| 44 | + uses: actions/upload-artifact@v4 |
43 | 45 | with: |
44 | | - name: my-artifact |
| 46 | + name: php-classes-list |
45 | 47 | path: ./php-classes.lst |
46 | 48 | ``` |
47 | 49 |
|
48 | | -## Arguments |
| 50 | +## Prerequisites |
49 | 51 |
|
50 | | -This action supports such arguments (used in `with` keyword): |
51 | | -| Argument | Required | Default value | Description | |
52 | | -|-------------|----------|----------------------|------------------------------------------------------------| |
53 | | -| output_file | Yes | | File where to write classes list | |
54 | | -| project_path | No | . | Path to the directory containing composer.json | |
| 52 | +Before using this action, ensure your workflow has: |
| 53 | +
|
| 54 | +1. PHP installed and configured |
| 55 | +2. Composer setup and available |
| 56 | +
|
| 57 | +The example workflow above demonstrates how to properly configure these prerequisites using the [`shivammathur/setup-php`](https://github.com/marketplace/actions/setup-php-action) action. |
| 58 | + |
| 59 | +## Configuration Options |
| 60 | + |
| 61 | +This action accepts the following parameters in the `with` section of your workflow: |
| 62 | + |
| 63 | +| Parameter | Required | Default | Description | |
| 64 | +|-------------|----------|---------|-------------------------------------------------------| |
| 65 | +| output_file | Yes | - | Destination file path for the generated classes list | |
| 66 | +| project_path | No | `.` | Path to the directory containing your composer.json | |
| 67 | + |
| 68 | +### Examples |
| 69 | + |
| 70 | +**Basic Usage:** |
| 71 | + |
| 72 | +Use this configuration when your `composer.json` file is located in the root directory of your repository. This is the most common setup for PHP projects. |
| 73 | + |
| 74 | +```yaml |
| 75 | +- name: Generate PHP classes list |
| 76 | + uses: impresscms-dev/generate-php-project-classes-list-file-action@v2 |
| 77 | + with: |
| 78 | + output_file: ./php-classes.lst |
| 79 | +``` |
| 80 | + |
| 81 | +**With Custom Project Path:** |
| 82 | + |
| 83 | +Use this configuration when your PHP project is in a subdirectory or when you have multiple PHP projects in a monorepo structure. This allows you to specify exactly which project's classes should be listed. |
| 84 | + |
| 85 | +```yaml |
| 86 | +- name: Generate PHP classes list |
| 87 | + uses: impresscms-dev/generate-php-project-classes-list-file-action@v2 |
| 88 | + with: |
| 89 | + output_file: ./php-classes.lst |
| 90 | + project_path: ./src |
| 91 | +``` |
| 92 | + |
| 93 | +**Generating Multiple Class Lists:** |
| 94 | + |
| 95 | +For repositories with multiple PHP projects, you can run the action multiple times with different configurations to generate separate class lists for each project. |
| 96 | + |
| 97 | +```yaml |
| 98 | +- name: Generate main project classes list |
| 99 | + uses: impresscms-dev/generate-php-project-classes-list-file-action@v2 |
| 100 | + with: |
| 101 | + output_file: ./main-classes.lst |
| 102 | + project_path: ./main |
| 103 | +
|
| 104 | +- name: Generate API project classes list |
| 105 | + uses: impresscms-dev/generate-php-project-classes-list-file-action@v2 |
| 106 | + with: |
| 107 | + output_file: ./api-classes.lst |
| 108 | + project_path: ./api |
| 109 | +``` |
55 | 110 |
|
56 | 111 | ## Development |
57 | 112 |
|
58 | | -### Setup |
| 113 | +### Local Setup |
| 114 | + |
| 115 | +Follow these steps to set up and work with the development environment for this action: |
| 116 | + |
| 117 | +#### 1. Install Dependencies |
| 118 | + |
| 119 | +First, install all required npm packages: |
59 | 120 |
|
60 | 121 | ```bash |
61 | | -# Install dependencies |
62 | 122 | npm install |
| 123 | +``` |
| 124 | + |
| 125 | +#### 2. Build the Action |
| 126 | + |
| 127 | +Compile the source code using esbuild: |
63 | 128 |
|
64 | | -# Pack the action |
| 129 | +```bash |
65 | 130 | npm run pack |
| 131 | +``` |
| 132 | + |
| 133 | +This creates a bundled version of the action in the `dist/` directory. For GitHub Actions, this directory must be committed to the repository as it contains the executable code that runs when others use this action. |
66 | 134 |
|
67 | | -# Run tests |
| 135 | +Note: If you forget to update the `dist/` folder after making changes, don't worry - there's a CI workflow that automatically builds and updates it when pull requests are submitted. |
| 136 | + |
| 137 | +#### 3. Run Tests |
| 138 | + |
| 139 | +Execute the test suite to verify functionality: |
| 140 | + |
| 141 | +```bash |
68 | 142 | npm test |
| 143 | +``` |
69 | 144 |
|
70 | | -# Lint code (both source and tests) |
71 | | -npm run lint |
| 145 | +#### 4. Code Quality |
72 | 146 |
|
73 | | -# Fix lint issues (both source and tests) |
74 | | -npm run lint:fix |
| 147 | +Check code quality with ESLint: |
75 | 148 |
|
76 | | -# Run all checks (lint, pack, test) |
77 | | -npm run all |
| 149 | +```bash |
| 150 | +npm run lint |
78 | 151 | ``` |
79 | 152 |
|
80 | | -### Packaging |
| 153 | +Automatically fix linting issues when possible: |
81 | 154 |
|
82 | | -This action uses [ncc](https://github.com/vercel/ncc) to compile the Node.js code and dependencies into a single file in the `dist/` folder. This allows the action to run quickly and reliably. |
| 155 | +```bash |
| 156 | +npm run lint:fix |
| 157 | +``` |
| 158 | + |
| 159 | +#### 5. Complete Verification |
83 | 160 |
|
84 | | -After making changes to the code, you should run: |
| 161 | +Run all checks (linting, building, and testing) in one command: |
85 | 162 |
|
86 | 163 | ```bash |
87 | | -npm run pack |
| 164 | +npm run all |
88 | 165 | ``` |
89 | 166 |
|
90 | | -The `dist/` folder should be committed to the repository. This is a requirement for GitHub Actions so that users can run the action without having to build it themselves. |
| 167 | +This is particularly useful before submitting a pull request. |
| 168 | + |
| 169 | +## Contributing |
91 | 170 |
|
92 | | -## How to contribute? |
| 171 | +Contributions are welcome! To contribute to this project: |
93 | 172 |
|
94 | | -If you want to add some functionality or fix bugs, you can fork, change and create pull request. If you not sure how this works, try [interactive GitHub tutorial](https://skills.github.com). |
| 173 | +1. [Fork the repository](https://github.com/impresscms-dev/generate-php-project-classes-list-file-action/fork) |
| 174 | +2. Create a feature branch and implement your changes |
| 175 | +3. Ensure tests pass and code meets quality standards |
| 176 | +4. [Submit a pull request](https://github.com/impresscms-dev/generate-php-project-classes-list-file-action/compare) |
95 | 177 |
|
96 | | -If you found any bug or have some questions, use [issues tab](https://github.com/impresscms-dev/generate-php-project-classes-list-file-action/issues) and write there your questions. |
| 178 | +For bug reports, questions, or feature requests, please use the [issues section](https://github.com/impresscms-dev/generate-php-project-classes-list-file-action/issues). |
0 commit comments