PHPackages                             yohns/project-structure-manager - 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. [CLI &amp; Console](/categories/cli)
4. /
5. yohns/project-structure-manager

ActiveLibrary[CLI &amp; Console](/categories/cli)

yohns/project-structure-manager
===============================

CLI tool to generate STRUCTURE.md files and create project structures from templates

0.1.1(11mo ago)05MITPHPPHP &gt;=8.3

Since Jun 8Pushed 11mo agoCompare

[ Source](https://github.com/Yohn/project-structure-manager)[ Packagist](https://packagist.org/packages/yohns/project-structure-manager)[ RSS](/packages/yohns-project-structure-manager/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (6)Versions (3)Used By (0)

Project Structure Manager
=========================

[](#project-structure-manager)

A powerful PHP 8.3+ composer library for generating and creating project directory structures using Markdown templates.

> The tests are not currently functioning properly.
> If I get time I'll trying to fix them. Pull requests are always welcome!

Features
--------

[](#features)

- **Generate STRUCTURE.md** - Scan any directory and create a markdown representation of its structure
- **Create from Templates** - Build project structures from predefined or custom markdown templates
- **CLI Interface** - Easy-to-use command line interface with tab completion
- **Template Variables** - Support for dynamic templates with variable substitution
- **Validation** - Built-in validation for structure files and templates
- **Dry Run Mode** - Preview what would be created before actually creating it
- **Extensible** - Object-oriented design following PHP 8.3+ best practices

Installation
------------

[](#installation)

```
composer require yohns/project-structure-manager
```

CLI Usage
---------

[](#cli-usage)

### Generate Structure Command

[](#generate-structure-command)

```
./vendor/bin/project-structure generate [path] [options]
```

#### Arguments

[](#arguments)

- `path` - Directory to scan (default: current directory)

#### Options

[](#options)

- `--output`, `-o` - Output file path (default: `STRUCTURE.md`)
- `--exclude`, `-e` - Patterns to exclude (can be used multiple times)
- `--max-depth`, `-d` - Maximum directory depth (default: `10`)
- `--show-preview`, `-p` - Show preview before saving

#### Examples

[](#examples)

```
# Basic generation
./vendor/bin/project-structure generate

# Custom output location
./vendor/bin/project-structure generate --output=docs/structure.md

# Exclude patterns
./vendor/bin/project-structure generate \
  --exclude=vendor \
  --exclude=node_modules \
  --exclude=.git \
  --exclude="*.log"

# Limit depth and preview
./vendor/bin/project-structure generate \
  --max-depth=5 \
  --show-preview

# Scan specific directory
./vendor/bin/project-structure generate /path/to/project \
  --output=/docs/project-structure.md
```

### Create Structure Command

[](#create-structure-command)

```
./vendor/bin/project-structure create  [options]
```

#### Arguments

[](#arguments-1)

- `structure-file` - Path to STRUCTURE.md file or template name

#### Options

[](#options-1)

- `--target`, `-t` - Target directory (default: current directory)
- `--template` - Treat input as template name
- `--variables`, `-v` - Template variables (key=value, can be used multiple times)
- `--dry-run` - Preview without creating
- `--force`, `-f` - Force creation/overwrite
- `--validate-only` - Only validate structure

#### Examples

[](#examples-1)

```
# Create from file
./vendor/bin/project-structure create structure.md

# Target specific directory
./vendor/bin/project-structure create structure.md --target=new-project

# Dry run preview
./vendor/bin/project-structure create structure.md --dry-run

# Use template with variables
./vendor/bin/project-structure create php-library --template \
  --variables PROJECT_NAME=MyLibrary \
  --variables AUTHOR="John Doe" \
  --variables NAMESPACE=MyLib

# Validate only
./vendor/bin/project-structure create structure.md --validate-only

# Force creation
./vendor/bin/project-structure create structure.md \
  --target=existing-dir \
  --force
```

PHP API Usage
-------------

[](#php-api-usage)

### StructureGenerator

[](#structuregenerator)

#### Constructor Options

[](#constructor-options)

```
use Yohns\ProjectStructure\Service\StructureGenerator;

// Scan current directory
$generator = new StructureGenerator();

// Scan specific directory
$generator = new StructureGenerator('/path/to/scan');
```

#### Configuration Methods

[](#configuration-methods)

```
// Set exclude patterns
$generator->setExcludePatterns([
    'vendor',
    'node_modules',
    '.git',
    '.DS_Store',
    '*.tmp',
    '*.log',
    'cache/*',
    'temp*'
]);
```

#### Generation Methods

[](#generation-methods)

```
// Generate structure (path, maxDepth)
$structure = $generator->generateStructure('', 10);

// Generate markdown
$markdown = $generator->generateMarkdown($structure);

// Save to file
$generator->saveToFile($markdown, 'custom-structure.md');
$generator->saveToFile($markdown, '/full/path/structure.md');
```

#### Complete Example

[](#complete-example)

```
$generator = new StructureGenerator('/my/project');
$generator->setExcludePatterns(['vendor', 'node_modules', '.git']);

$structure = $generator->generateStructure('', 8);
$markdown = $generator->generateMarkdown($structure);
$generator->saveToFile($markdown, 'docs/project-structure.md');
```

### StructureCreator

[](#structurecreator)

#### Constructor Options

[](#constructor-options-1)

```
use Yohns\ProjectStructure\Service\StructureCreator;

// Create in current directory
$creator = new StructureCreator();

// Create in specific directory
$creator = new StructureCreator('/target/path');
```

#### Creation Methods

[](#creation-methods)

```
// From markdown file
$result = $creator->createFromMarkdownFile('structure.md', $dryRun = false);

// From markdown content
$content = file_get_contents('structure.md');
$result = $creator->createFromMarkdownContent($content, $dryRun = false);

// From template
$variables = ['PROJECT_NAME' => 'MyApp', 'AUTHOR' => 'John Doe'];
$result = $creator->createFromTemplate('php-library', $variables, $dryRun = false);
```

#### Validation

[](#validation)

```
// Validate structure
$errors = $creator->validateStructure($content);
if (empty($errors)) {
    $result = $creator->createFromMarkdownContent($content);
} else {
    foreach ($errors as $error) {
        echo "Error: {$error}\n";
    }
}
```

#### Complete Example

[](#complete-example-1)

```
$creator = new StructureCreator('/new/project');

// Validate first
$content = file_get_contents('my-structure.md');
$errors = $creator->validateStructure($content);

if (empty($errors)) {
    // Dry run preview
    $preview = $creator->createFromMarkdownContent($content, true);
    echo "Would create " . count($preview['files']) . " files\n";

    // Create for real
    $result = $creator->createFromMarkdownContent($content, false);
    echo "Created " . count($result['files']) . " files\n";
}
```

Configuration Options Reference
-------------------------------

[](#configuration-options-reference)

### Exclude Patterns

[](#exclude-patterns)

```
// Default patterns
$defaultExcludes = [
    'vendor',       // Composer dependencies
    'node_modules', // NPM dependencies
    '.git',         // Git repository
    '.DS_Store',    // macOS system files
    '*.tmp',        // Temporary files
    '*.log'         // Log files
];

// Pattern types
$patterns = [
    'exact-name',           // Exact directory/file name
    '*.extension',          // File extension wildcard
    'prefix*',              // Prefix wildcard
    '*suffix',              // Suffix wildcard
    'dir/*',                // Directory contents
    '.hidden',              // Hidden files/directories
];
```

### Template Variables

[](#template-variables)

```
// Simple substitution
$variables = [
    'PROJECT_NAME' => 'MyProject',
    'AUTHOR' => 'John Doe',
    'NAMESPACE' => 'MyProject\\Core',
    'MAIN_CLASS' => 'Application'
];

// Conditional variables
$variables = [
    'DOCS' => true,         // {{if DOCS}}content{{/if}}
    'LICENSE' => 'MIT',     // {{if LICENSE}}content{{/if}}
    'TESTING' => false      // Empty = false condition
];
```

### File Content Templates

[](#file-content-templates)

Default content by extension:

- `.php` - PHP declaration header
- `.js` - 'use strict' directive
- `.html` - Basic HTML structure
- `.json` - Empty JSON object `{}`
- `.md` - Basic markdown structure
- `.yml/.yaml` - YAML comment header
- `.css` - CSS comment header

### Validation Rules

[](#validation-rules)

- Path length limits
- Invalid characters check
- Reserved filename detection
- Duplicate path prevention
- Directory depth limits
- File permission validation

Built-in Templates
------------------

[](#built-in-templates)

### php-library

[](#php-library)

Standard PHP library structure with PSR-4 autoloading.

**Variables:**

- `PROJECT_NAME` (required)
- `NAMESPACE` (optional)
- `MAIN_CLASS` (optional)
- `AUTHOR` (optional)
- `DESCRIPTION` (optional)

### web-app

[](#web-app)

Basic web application with MVC structure.

**Variables:**

- `PROJECT_NAME` (required)
- `FRAMEWORK` (optional)
- `DATABASE` (optional)

Error Handling
--------------

[](#error-handling)

The library provides specific exception types:

- `StructureCreationException` - File/directory creation errors
- `ParseException` - Markdown parsing errors
- `ValidationException` - Structure validation errors
- `TemplateException` - Template processing errors
- `FilesystemException` - File system access errors

Requirements
------------

[](#requirements)

- PHP 8.3+
- Composer
- Extensions: json, mbstring

Dependencies
------------

[](#dependencies)

- **symfony/console** - CLI framework
- **league/flysystem** - Filesystem abstraction
- **league/commonmark** - Markdown processing
- **symfony/filesystem** - File operations

Contributing
------------

[](#contributing)

1. Fork the repository
2. Create a feature branch
3. Make your changes following PSR-12 standards
4. Add tests for new functionality
5. Submit a pull request

License
-------

[](#license)

MIT License - see LICENSE file for details.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance52

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

2

Last Release

339d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c53f441885ec90d8d6e547f4c9023da12f10229c3848059e19b6aba9be1859a?d=identicon)[Yohn](/maintainers/Yohn)

---

Top Contributors

[![Yohn](https://avatars.githubusercontent.com/u/2002591?v=4)](https://github.com/Yohn "Yohn (2 commits)")

---

Tags

directories-utilitydirectory-structure-generatordirectory-treephp-structuresstructurestructure-generator

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/yohns-project-structure-manager/health.svg)

```
[![Health](https://phpackages.com/badges/yohns-project-structure-manager/health.svg)](https://phpackages.com/packages/yohns-project-structure-manager)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.6k509.9M17.0k](/packages/laravel-framework)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[humbug/php-scoper

Prefixes all PHP namespaces in a file or directory.

7963.0M35](/packages/humbug-php-scoper)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[crunzphp/crunz

Schedule your tasks right from the code.

2292.0M6](/packages/crunzphp-crunz)

PHPackages © 2026

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