Skip to content

Commit fa42de8

Browse files
authored
Merge pull request #24 from MekDrop/fxi/readme.md
Improved README.md
2 parents 58d1008 + 3c25792 commit fa42de8

File tree

1 file changed

+119
-37
lines changed

1 file changed

+119
-37
lines changed

README.md

Lines changed: 119 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,178 @@
11
[![License](https://img.shields.io/github/license/impresscms-dev/generate-php-project-classes-list-file-action.svg)](LICENSE) [![GitHub release](https://img.shields.io/github/release/impresscms-dev/generate-php-project-classes-list-file-action.svg)](https://github.com/impresscms-dev/generate-php-project-classes-list-file-action/releases)
22

3-
# Generate PHP project classes list file action
3+
# Generate PHP Project Classes List File Action
44

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.
66

77
## Usage
88

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:
1010
```yaml
11-
name: Generate PHP project class list as artifact
11+
name: Generate PHP Class List
1212

1313
on:
1414
push:
15+
branches: [main]
1516

1617
jobs:
17-
get_php_classes_list:
18+
generate-class-list:
1819
runs-on: ubuntu-latest
1920
steps:
20-
- name: Checkouting project code...
21+
- name: Checkout repository
2122
uses: actions/checkout@v4
2223

23-
- name: Install PHP
24-
uses: shivammathur/setup-php@master
24+
- name: Setup PHP environment
25+
uses: shivammathur/setup-php@v2
2526
with:
2627
php-version: 8.4
2728
extensions: curl, gd, pdo_mysql, json, mbstring, pcre, session
2829
ini-values: post_max_size=256M
2930
coverage: none
3031
tools: composer:v2
3132

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
3435

35-
- name: Getting PHP classes list...
36+
- name: Generate PHP classes list
3637
uses: impresscms-dev/generate-php-project-classes-list-file-action@v2
3738
with:
3839
output_file: ./php-classes.lst
3940
# Optional: specify a different path if composer.json is not in the root
4041
# project_path: ./src
4142

42-
- uses: actions/upload-artifact@v4
43+
- name: Upload classes list as artifact
44+
uses: actions/upload-artifact@v4
4345
with:
44-
name: my-artifact
46+
name: php-classes-list
4547
path: ./php-classes.lst
4648
```
4749
48-
## Arguments
50+
## Prerequisites
4951
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+
```
55110

56111
## Development
57112

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:
59120

60121
```bash
61-
# Install dependencies
62122
npm install
123+
```
124+
125+
#### 2. Build the Action
126+
127+
Compile the source code using esbuild:
63128

64-
# Pack the action
129+
```bash
65130
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.
66134

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
68142
npm test
143+
```
69144

70-
# Lint code (both source and tests)
71-
npm run lint
145+
#### 4. Code Quality
72146

73-
# Fix lint issues (both source and tests)
74-
npm run lint:fix
147+
Check code quality with ESLint:
75148

76-
# Run all checks (lint, pack, test)
77-
npm run all
149+
```bash
150+
npm run lint
78151
```
79152

80-
### Packaging
153+
Automatically fix linting issues when possible:
81154

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
83160

84-
After making changes to the code, you should run:
161+
Run all checks (linting, building, and testing) in one command:
85162

86163
```bash
87-
npm run pack
164+
npm run all
88165
```
89166

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
91170

92-
## How to contribute?
171+
Contributions are welcome! To contribute to this project:
93172

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)
95177

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

Comments
 (0)