PHPackages                             naneau/filegen - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. naneau/filegen

ActiveLibrary[File &amp; Storage](/categories/file-storage)

naneau/filegen
==============

A PHP File and Directory Generating Tool

0.0.5(8y ago)529.9k1MITPHP

Since Jul 8Pushed 5y ago1 watchersCompare

[ Source](https://github.com/naneau/filegen)[ Packagist](https://packagist.org/packages/naneau/filegen)[ RSS](/packages/naneau-filegen/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (6)Used By (0)

FileGen
=======

[](#filegen)

[![Build Status](https://camo.githubusercontent.com/acf1e2a2f26a392deede759f2e63aaf7317dd9aa6aab9aeab45caf88712741d5/68747470733a2f2f7472617669732d63692e6f72672f6e616e6561752f66696c6567656e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/naneau/filegen)[![SensioLabsInsight](https://camo.githubusercontent.com/c2010701680125c12d6090f6a9c80c7c54350c693de2d04f13bcfc2ae281ee68/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f34356261313039652d663435362d343639632d386366322d6662363231666133633036392f6d696e692e706e67)](https://insight.sensiolabs.com/projects/45ba109e-f456-469c-8cf2-fb621fa3c069)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/60bbc327f35f485473e0bd1771ad1e3d3614ffde13373334ea8242cde054f89a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6e616e6561752f66696c6567656e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/naneau/filegen/?branch=master)

A small tool to aid in the creation of (complicated) file and directory

layouts.

```
use Naneau\FileGen\Structure;
use Naneau\FileGen\Generator;

// Specify a structure to be generated
$structure = new Structure;
$structure
    ->directory('foo')
    ->file('bar/baz', 'these are the file contents');
    ->link('/some/file/somewhere', 'qux');

// Generate the structure
$generator = new Generator('/output/directory');
$generator->generate($structure);
```

will output:

```
- /output/directory/
    - foo/
    - bar/
        - baz
    - qux => /some/file/somewhere

```

Examples
--------

[](#examples)

### Copy A File

[](#copy-a-file)

Copying an existing file to a new file in the structure to be generated is easy.

```
use Naneau\FileGen\Structure;
use Naneau\FileGen\File\Contents\Copy;

$structure = new Structure;
$structure->file('foo', new Copy('/from/this/file'));
```

### Use a Twig Template

[](#use-a-twig-template)

Files can be given content using a [Twig](http://twig.sensiolabs.org/)template.

```
use Naneau\FileGen\Structure;
use Naneau\FileGen\File\Contents\Twig;

// $twig = ...

// Load a template
$template = $twig->load('some_template.twig');

// Parameters for the template
$parameters = array('foo' => 'bar')

$structure = new Structure;
$structure->file('foo', new Twig($template, $parameters));
```

### Set up A Parameter Specification Alongside A Structure

[](#set-up-a-parameter-specification-alongside-a-structure)

In some cases you'll want to specify parameters to be used by your structure beforehand. These parameters can then be queried for using the console helper (see below), and used in Twig templates.

```
use Naneau\FileGen\Generator;
use Naneau\FileGen\Structure;
use Naneau\FileGen\File\Contents\Twig;

// $twig = ...
$template = ;
$structure = new Structure;
$structure
    // A parameter "foo" is expected
    ->param('foo')

    // A bar parameter with a description
    ->param('bar', 'Please specify "bar"')

    // Can use {{ foo }} and {{ bar }}
    ->file('someFile', new Twig($twig->load('someFile.twig'));

    // Can also use {{ foo }} and {{ bar }}
    ->file('anotherFile', new Twig($twig->load('anotherFile.twig'));

// Set a default value for foo
$structure->getParameterDefinition()->get('foo')->setDefaultValue('Foo!');

// Pass values for the structure's parameters to the generator
$generator = new Generator('/output/directory', array(
    'foo' => 'foo!'
    'bar' => 12345
));

// Generate the structure
$generator->generate($structure);
```

Console Helper
--------------

[](#console-helper)

FileGen ships with a a (Symfony Console Helper\]() that will use the [built-in question helper](http://symfony.com/doc/current/components/console/helpers/questionhelper.html)to ask for parameter values.

Simply add the helper to your console helper set:

```
use Naneau\FileGen\Console\Helper\ParameterHelper;

// $application = ...
$application->getHelperSet()->set(new ParameterHelper, 'filegenParameters');
```

And use it in your commands:

```
protected function execute(InputInterface $input, OutputInterface $output)
{
    // $structure = ...

    $helper = $this->getHelper('filegenParameters');

    // Ask for all parameters one by one
    $parameters = $helper->askParameters($structure, $input, $output);

    // Ask for a single parameter
    $fooParameter = $structure->getParameterDefinition()->get('foo');
    $fooValue = $helper->askParameter($fooParameter, $input, $output);
}
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~273 days

Total

5

Last Release

3231d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6d7b50b7ec10565e66591b3b5f81f00a499cd77a6b87564393256a8b27e03e86?d=identicon)[naneau](/maintainers/naneau)

---

Top Contributors

[![naneau](https://avatars.githubusercontent.com/u/89551?v=4)](https://github.com/naneau "naneau (22 commits)")[![stephan281094](https://avatars.githubusercontent.com/u/4006802?v=4)](https://github.com/stephan281094 "stephan281094 (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/naneau-filegen/health.svg)

```
[![Health](https://phpackages.com/badges/naneau-filegen/health.svg)](https://phpackages.com/packages/naneau-filegen)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k511.3M2.2k](/packages/aws-aws-sdk-php)[terminal42/contao-fineuploader

FineUploader bundle for Contao Open Source CMS

2052.9k4](/packages/terminal42-contao-fineuploader)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
