Small utility to organize tasks to make a PHP project production-ready.
  • PHP 99.1%
  • Shell 0.9%
Find a file
C. Fahner a6bc8e1ba6 Report task updates through the CLI (#11)
Resolves #8.

Update `Builder::build()` to return an iterable of all task updates.
Update the main PHP script to report these updates to the CLI.
Add `Task\Warning` example to README.

Reviewed-on: #11
2026-06-28 10:33:30 +02:00
src Report task updates through the CLI (#11) 2026-06-28 10:33:30 +02:00
tests Report task updates through the CLI (#11) 2026-06-28 10:33:30 +02:00
.gitignore Add .gitignore 2026-06-24 17:00:36 +02:00
build-internal.php Report task updates through the CLI (#11) 2026-06-28 10:33:30 +02:00
composer.json Add composer files 2026-06-24 20:06:26 +02:00
composer.lock Add composer files 2026-06-24 20:06:26 +02:00
LICENSE Add LICENSE 2026-06-24 20:06:54 +02:00
phpstan.neon Classes not found in {main} (#6) 2026-06-26 06:50:42 +02:00
phpunit.xml Add phpunit.xml 2026-06-24 20:06:45 +02:00
README.md Report task updates through the CLI (#11) 2026-06-28 10:33:30 +02:00
slendium-build Classes not found in {main} (#6) 2026-06-26 06:50:42 +02:00

Slendium Build

Small utility for making PHP projects production-ready. Validating code using unit tests or static analysis should happen before this tool runs.

Installation

Simply run composer require slendium/build to add it to your project.

Usage

From your project root, run ./vendor/bin/slendium-build to start the "build" in the current working directory. WARNING: tasks may remove local files, so make sure to only run this command on a clean copy of the project.

The script will go through the following steps:

  1. Run composer install --no-dev --classmap-authoritative
  2. Find a list of tasks to run
    1. Either directly from the arguments, where each argument should be a PHP class-string<Task>
    2. Or from a file called SlendiumBuild.json in the current working directory
  3. Run the tasks in the given order, if all classes exist

SlendiumBuild.json

This JSON file can be put in your project root to specify build options. Currently it supports one key:

  • tasks - a non-empty list of class-string<Task>'s to run in the given order

Tasks

To define your own task, simply create a PHP class that implements the Task interface and add the fully qualified class name to the script arguments or to the JSON configuration file.

Example task

class MyTask implements Task {

	#[Override]
	public function run(BuildEnvironment $environment): iterable {
		$items = \iterator_to_array(ClassmapSearch::byInstanceOf($environment->classmap, Marker::class));

		$progress = 0;
		foreach ($items as $class => file) {
			MyClassAnalysisUtil::analyze($class);

			$progress += 1;
			yield new Task\ProgressUpdate($progress, \count($items));
		}

		if ($progress === 0) {
			yield new Task\Warning("Project did not contain any Marker classes to analyze");
		}
	}

}