PHPackages                             purwantoid/package-generator - 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. [Framework](/categories/framework)
4. /
5. purwantoid/package-generator

ActiveLaravel-package[Framework](/categories/framework)

purwantoid/package-generator
============================

Easy creation with Laravel package.

v1.1.0(5mo ago)06PHPPHP ^8.3

Since Dec 14Pushed 5mo agoCompare

[ Source](https://github.com/purwantoid/package-generator)[ Packagist](https://packagist.org/packages/purwantoid/package-generator)[ RSS](/packages/purwantoid-package-generator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (10)Versions (2)Used By (0)

Laravel Package Generator
=========================

[](#laravel-package-generator)

Easy creation of Laravel packages with customizable stub templates.

Features
--------

[](#features)

- Generate complete Laravel package structure
- Customizable stub templates for all generated files
- Support for conditional content (e.g., test files)
- Configurable template paths
- Automatic stub file discovery
- Template syntax validation

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

[](#installation)

```
composer require purwantoid/package-generator
```

Usage
-----

[](#usage)

### Basic Package Generation

[](#basic-package-generation)

```
php artisan make:package VendorName PackageName
```

### Generate Package with Tests

[](#generate-package-with-tests)

```
php artisan make:package VendorName PackageName --with-tests
```

Template System
---------------

[](#template-system)

The package generator uses external stub files for all templates, making it easy to customize the generated package structure.

### Stub File Structure

[](#stub-file-structure)

```
stubs/
├── php/
│   ├── service-provider.stub
│   ├── main-class.stub
│   ├── test-case.stub
│   └── example-test.stub
├── config/
│   ├── config.stub
│   └── phpunit.stub
├── composer/
│   └── composer.json.stub
├── docs/
│   ├── readme.stub
│   └── license.stub
└── routes/
    └── web.stub

```

### Template Variables

[](#template-variables)

All stub files support the following placeholder variables:

- `{{PACKAGE_NAME}}` - Original package name
- `{{PACKAGE_NAME_KEBAB}}` - Package name in kebab-case
- `{{PACKAGE_NAME_STUDLY}}` - Package name in StudlyCase
- `{{VENDOR_NAME}}` - Original vendor name
- `{{VENDOR_NAME_KEBAB}}` - Vendor name in kebab-case
- `{{VENDOR_NAME_STUDLY}}` - Vendor name in StudlyCase
- `{{NAMESPACE}}` - Full namespace (VendorName\\PackageName)
- `{{NAMESPACE_ESCAPED}}` - Escaped namespace for JSON (VendorName\\\\PackageName)
- `{{COMPOSER_NAME}}` - Composer package name (vendor-name/package-name)
- `{{CLASS_NAME}}` - Main class name
- `{{SERVICE_PROVIDER_CLASS}}` - Service provider class name
- `{{CURRENT_YEAR}}` - Current year
- `{{WITH_TESTS}}` - Boolean indicating if tests should be included

### Conditional Content

[](#conditional-content)

Stub files support conditional blocks for optional content:

```
{{#WITH_TESTS}}
// This content will only be included when --with-tests option is used
class ExampleTest extends TestCase
{
    // Test methods...
}
{{/WITH_TESTS}}
```

### Customizing Templates

[](#customizing-templates)

You can customize the generated package structure by modifying the stub files in the `stubs/` directory. Changes to stub files will be reflected immediately in newly generated packages.

#### Custom Stub Paths

[](#custom-stub-paths)

You can configure custom paths for specific stub files:

```
// In a service provider or configuration
$loader = new StubFileLoader(
    $filesystem,
    $defaultStubsPath,
    [
        'service-provider' => '/path/to/custom/service-provider.stub',
        'main-class' => '/path/to/custom/main-class.stub'
    ]
);
```

#### Template Validation

[](#template-validation)

The system includes built-in validation for template syntax:

```
$engine = new StubTemplateEngine($loader, $processor, $filesystem);

// Validate template syntax
$errors = $engine->validateTemplateIntegrity('service-provider');
if (!empty($errors)) {
    // Handle validation errors
}

// Validate required variables
$engine->processTemplate('service-provider', $variables, false, true);
```

Configuration
-------------

[](#configuration)

The package supports various configuration options for customizing the template system:

### Stub Directory Configuration

[](#stub-directory-configuration)

```
// Configure custom stubs directory
$loader = new StubFileLoader($filesystem, '/custom/stubs/path');

// Enable fallback to default stubs
$loader = new StubFileLoader(
    $filesystem,
    '/primary/stubs/path',
    [],
    true, // fallback enabled
    '/fallback/stubs/path'
);
```

### Template Discovery

[](#template-discovery)

The system automatically discovers new stub files without requiring code changes:

```
$engine = new StubTemplateEngine($loader, $processor, $filesystem);

// Get all available stub files
$availableStubs = $engine->getAvailableStubs();

// Check for new stub files
$newStubs = $engine->getNewStubs($previousStubList);
```

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

[](#error-handling)

The template system provides comprehensive error handling:

- **Missing stub files**: Clear error messages with troubleshooting steps
- **Invalid template syntax**: Detailed syntax validation with line numbers
- **Undefined variables**: Validation of required template variables
- **File permissions**: Graceful handling of permission errors
- **Path security**: Protection against path traversal attacks

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

[](#requirements)

- PHP 8.3 or higher
- Laravel 9.0, 10.0, 11.0, or 12.0
- Illuminate Filesystem package

License
-------

[](#license)

This package is open-sourced software licensed under the MIT license.

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

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

Changelog
---------

[](#changelog)

### Version 2.0.0

[](#version-200)

- Refactored to use external stub template system
- Added template syntax validation
- Improved error handling and user feedback
- Added support for conditional content blocks
- Implemented configurable template paths
- Added automatic stub file discovery

### Version 1.0.0

[](#version-100)

- Initial release with hardcoded templates

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance73

Regular maintenance activity

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

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

Unknown

Total

1

Last Release

150d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9a03748e2f386da58d91eb04740ae9949b196be6e0a8f2fed253ec7ba0c7a44a?d=identicon)[smallerid](/maintainers/smallerid)

---

Top Contributors

[![purwantoid](https://avatars.githubusercontent.com/u/12179541?v=4)](https://github.com/purwantoid "purwantoid (1 commits)")

---

Tags

laravellaravel-packageeasy packagelaravel package package

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/purwantoid-package-generator/health.svg)

```
[![Health](https://phpackages.com/badges/purwantoid-package-generator/health.svg)](https://phpackages.com/packages/purwantoid-package-generator)
```

###  Alternatives

[laravel/ui

Laravel UI utilities and presets.

2.7k134.9M601](/packages/laravel-ui)[laravel/breeze

Minimal Laravel authentication scaffolding with Blade and Tailwind.

3.0k31.3M148](/packages/laravel-breeze)[graham-campbell/markdown

Markdown Is A CommonMark Wrapper For Laravel

1.3k7.1M64](/packages/graham-campbell-markdown)[laravel/wayfinder

Generate TypeScript representations of your Laravel actions and routes.

1.7k4.1M69](/packages/laravel-wayfinder)[laravel/installer

Laravel application installer.

83610.7M20](/packages/laravel-installer)[laravel/vapor-cli

The Laravel Vapor CLI

31310.7M8](/packages/laravel-vapor-cli)

PHPackages © 2026

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