ysato / catalyst
An Artisan command package for Laravel to improve code quality and project structure.
Requires
- php: ^8.2
- composer/composer: ^2.6
- digitalrevolution/php-codesniffer-baseline: >=1.0.0
- doctrine/coding-standard: >=10.0.0
- illuminate/console: ^11.26|^12.0
- illuminate/support: ^11.26|^12.0
- larastan/larastan: ^3.0
- laravel/prompts: ^0.3.5
- phpmd/phpmd: >=2.12.0
- psalm/plugin-laravel: ^3.0
- spatie/temporary-directory: ^2.2
- squizlabs/php_codesniffer: >=3.7.1
- symfony/filesystem: ^7.1
- symfony/finder: ^7.1
- twig/twig: ^3.20
- vimeo/psalm: >=6.12.0
Requires (Dev)
- laravel/framework: ^11.26|^12.0
- phpunit/phpunit: ^10.5|^11.0|^12.0.1
- sebastian/diff: ^5.1
- spatie/phpunit-snapshot-assertions: ^5.2
README
A scaffolding tool to accelerate the setup of Laravel projects.
About This Package
This package generates the necessary file structure for initializing a Laravel project using a unified template system with enhanced extensibility.
Important Note: This command will always overwrite existing files.
To prevent unintended changes, you are expected to carefully review the output with a tool like git diff
after running the command, and then selectively commit only the changes you want to adopt.
The tool's role is to generate a diff based on the latest template; how that diff is handled is delegated to the user.
Installation
Prerequisites (Strongly Recommended)
This package strongly recommends installing just, a command runner that simplifies Docker-based development workflows.
Please refer to the installation guide for your platform. For example, on macOS with Homebrew:
brew install just
Package Installation
Run the following command to install:
composer require --dev ysato/catalyst
Usage
This command will prompt you for necessary information interactively when run without arguments. For automation, you can pass the information as arguments to run it non-interactively.
Interactive Execution
If you run the command without any arguments, you will be prompted sequentially for the vendor name, package name, and PHP version.
php artisan catalyst:scaffold
Execution with Arguments (for Automation)
For use in CI/CD scripts, you can run the command non-interactively by passing arguments in the following format.
Format:
php artisan catalyst:scaffold <vendor> <package> <php>
Argument | Description |
---|---|
<vendor> |
(Required) The vendor name for namespacing (e.g., Ysato ). |
<package> |
(Required) The package name that follows the vendor (e.g., Catalyst ). |
<php> |
(Required) The PHP version to configure for the project (e.g., 8.3 ). |
Example:
php artisan catalyst:scaffold MyVendor MyProject 8.3
Options
Option | Description |
---|---|
--with-ca-file |
(Optional) Path to a custom CA certificate file to trust within the container. Needed when behind a corporate proxy. |
Example with Arguments and Options:
php artisan catalyst:scaffold MyCorp WebApp 8.3 --with-ca-file=./certs/certificate.pem
Post-Setup Manual Steps
Initial QA Setup
When running just composer lints
for the first time on a newly scaffolded project, you may encounter errors due to existing code patterns. To resolve these, create baseline files for each QA tool:
PHP_CodeSniffer Baseline
vendor/bin/phpcs --report=\\DR\\CodeSnifferBaseline\\Reports\\Baseline --report-file=phpcs.baseline.xml --basepath=.
PHPMD Baseline
vendor/bin/phpmd app,src text ./phpmd.xml --generate-baseline
PHPStan Baseline
vendor/bin/phpstan analyse --generate-baseline
Psalm Baseline
vendor/bin/psalm --set-baseline
Importing Branch Protection Rulesets
This project generates predefined GitHub branch protection rulesets as JSON files in the .github/rulesets
directory. These must be manually applied to your repository.
Prerequisites
- You need admin access to the GitHub repository where you want to import these rulesets.
Importing via GitHub UI
-
Navigate to your repository on GitHub.
-
Click on Settings.
-
In the left sidebar, under the "Code and automation" section, click on Rules, then Rulesets.
-
Click the "Import ruleset" button.
-
When prompted to upload a JSON file, select a
.json
file from the.github/rulesets/
directory. -
Review the imported settings and click "Create".
-
Repeat for other ruleset files as needed.
Note: Carefully review the "Target branches" section for each ruleset after import to ensure they apply to the intended branches (e.g.,
main
,develop
).
For Contributors
Development Setup
This project uses Docker for development. Use the provided justfile
commands.
Available Commands
just build
- Builds the necessary Docker imagesjust composer
- Runs composer commands via Dockerjust act
- Runs GitHub Actions locallyjust clean
- Removes the Docker imagesjust help
- Displays this help message
Compatibility Testing
To install the oldest compatible versions of dependencies and ensure this package works reliably in diverse environments, run the following command:
composer update --prefer-lowest
License
This package is provided under the MIT License.