ju1ius/luigi

Need to generate PHP code? Luigi does the plumbing!

Maintainers

Details

github.com/ju1ius/luigi

Source

Issues

Installs: 1 511

Dependents: 3

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/ju1ius/luigi

1.0 2023-02-05 22:35 UTC

This package is auto-updated.

Last update: 2025-10-06 06:20:27 UTC


README

codecov

Need to generate PHP code? Luigi does the plumbing!

Installation

composer require ju1ius/luigi

Basic usage

use ju1ius\Luigi\CodeBuilder;

$code = CodeBuilder::create();
// The `raw` method adds verbatim code
$code->raw("return [\n");
// The `indent` method increases the indent level
$code->indent();
// The `write` does the same as `raw` but respects the indent level
$code->write("42,\n");
// The `writeln` method does the same as `write`, but adds a newline character after each argument.
$code->writeln('33,', '66,');
// The `dedent` method decreases the indent level
$code->dedent();
$code->writeln('];');
// CodeBuilder implements the `Stringable` interface
echo $code;

This is the expected output:

return [
    42,
    33,
    66,
];