A GitHub Action that generates a comprehensive list of classes in your PHP project. This action is designed to work with projects that use Composer for dependency management.
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:
name: Generate PHP Class List
on:
push:
branches: [main]
jobs:
generate-class-list:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup PHP environment
uses: shivammathur/setup-php@v2
with:
php-version: 8.4
extensions: curl, gd, pdo_mysql, json, mbstring, pcre, session
ini-values: post_max_size=256M
coverage: none
tools: composer:v2
- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Generate PHP classes list
uses: impresscms-dev/generate-php-project-classes-list-file-action@v2
with:
output_file: ./php-classes.lst
# Optional: specify a different path if composer.json is not in the root
# project_path: ./src
- name: Upload classes list as artifact
uses: actions/upload-artifact@v4
with:
name: php-classes-list
path: ./php-classes.lstBefore using this action, ensure your workflow has:
- PHP installed and configured
- Composer setup and available
The example workflow above demonstrates how to properly configure these prerequisites using the shivammathur/setup-php action.
This action accepts the following parameters in the with section of your workflow:
| Parameter | Required | Default | Description |
|---|---|---|---|
| output_file | Yes | - | Destination file path for the generated classes list |
| project_path | No | . |
Path to the directory containing your composer.json |
Basic Usage:
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.
- name: Generate PHP classes list
uses: impresscms-dev/generate-php-project-classes-list-file-action@v2
with:
output_file: ./php-classes.lstWith Custom Project Path:
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.
- name: Generate PHP classes list
uses: impresscms-dev/generate-php-project-classes-list-file-action@v2
with:
output_file: ./php-classes.lst
project_path: ./srcGenerating Multiple Class Lists:
For repositories with multiple PHP projects, you can run the action multiple times with different configurations to generate separate class lists for each project.
- name: Generate main project classes list
uses: impresscms-dev/generate-php-project-classes-list-file-action@v2
with:
output_file: ./main-classes.lst
project_path: ./main
- name: Generate API project classes list
uses: impresscms-dev/generate-php-project-classes-list-file-action@v2
with:
output_file: ./api-classes.lst
project_path: ./apiFollow these steps to set up and work with the development environment for this action:
First, install all required npm packages:
npm installCompile the source code using esbuild:
npm run packThis 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.
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.
Execute the test suite to verify functionality:
npm testCheck code quality with ESLint:
npm run lintAutomatically fix linting issues when possible:
npm run lint:fixRun all checks (linting, building, and testing) in one command:
npm run allThis is particularly useful before submitting a pull request.
Contributions are welcome! To contribute to this project:
- Fork the repository
- Create a feature branch and implement your changes
- Ensure tests pass and code meets quality standards
- Submit a pull request
For bug reports, questions, or feature requests, please use the issues section.