PHPackages                             knausdev/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. knausdev/package-generator

ActiveLibrary[Framework](/categories/framework)

knausdev/package-generator
==========================

Laravel package generator with custom structure and components

0212↓33.3%PHP

Since Jul 18Pushed 10mo agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

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

[](#knausdev-laravel-package-generator)

A Laravel package generator that creates packages with a custom code style and structure. This tool helps you quickly scaffold Laravel packages with models, controllers, services, and frontend components.

Features
--------

[](#features)

- Generate composer packages or domain-specific implementations
- Create models with fillable fields and casts
- Generate migrations with proper schema definitions
- Create controllers with resource methods
- Implement service layer for business logic
- Generate form requests with validation rules
- Create API resources for response formatting
- Generate Vue components for frontend (optional)
- Support for field management (add, update, remove)
- Customizable templates and configurations

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

[](#installation)

You can install the package via composer:

```
composer require knausdev/package-generator
```

Or develop it locally:

```
# Create a packages directory in your Laravel project
mkdir -p packages/knausdev/package-generator

# Clone this repository into the directory or create files manually
git clone https://github.com/your-username/laravel-package-generator.git packages/knausdev/package-generator

# Add to composer.json repositories
"repositories": [
    {
        "type": "path",
        "url": "./packages/knausdev/package-generator"
    }
]

# Require the package
composer require knausdev/package-generator
```

After installation, run the setup command:

```
php artisan knausdev:install
```

This will:

- Create necessary directories (packages, domains)
- Generate route registration files
- Update main route files to include domain routes
- Publish configuration files

Publishing Configuration
------------------------

[](#publishing-configuration)

```
php artisan vendor:publish --provider="KnausDev\PackageGenerator\PackageGeneratorServiceProvider" --tag="package-generator-config"
```

Customizing Templates
---------------------

[](#customizing-templates)

You can publish and customize the stub templates:

```
php artisan knausdev:publish-stubs
```

This will copy all stub templates to `stubs/vendor/knausdev/package-generator` where you can modify them to match your coding style.

Usage
-----

[](#usage)

### Creating a New Package

[](#creating-a-new-package)

```
php artisan knausdev:make-package YourPackageName
```

Options:

- `--type=composer` - Package type (composer or domain), default: composer
- `--namespace=YourNamespace` - The namespace of the package, default: KnausDev
- `--path=/custom/path` - Optional custom path for package
- `--model=CustomModel` - Optional model name (default derives from package name)
- `--api-only` - Whether the package is API only (no frontend)
- `--api-version=v2` - API version to use, default: v1

### Adding a Model to an Existing Package

[](#adding-a-model-to-an-existing-package)

```
php artisan knausdev:package-model YourPackageName NewModelName
```

Options are the same as for `make-package`.

### Managing Fields

[](#managing-fields)

```
# Add a field
php artisan knausdev:package-field add YourPackageName ModelName

# Update a field
php artisan knausdev:package-field update YourPackageName ModelName --field=fieldName

# Remove a field
php artisan knausdev:package-field remove YourPackageName ModelName --field=fieldName
```

### Running Migrations for Domain Packages

[](#running-migrations-for-domain-packages)

Domain packages don't use the standard Laravel migration discovery. Use our custom command to run migrations:

```
# Run migrations for all domains
php artisan knausdev:domain-migrate

# Run migrations for a specific domain
php artisan knausdev:domain-migrate YourDomainName

# Fresh migrations (wipes database)
php artisan knausdev:domain-migrate --fresh

# With seeding
php artisan knausdev:domain-migrate --seed
```

### Registering Routes from Domain Packages

[](#registering-routes-from-domain-packages)

Domain routes aren't automatically registered. Use our command to generate a registration file:

```
php artisan knausdev:domain-routes
```

This command scans all domain packages for route files and generates:

- `routes/domain_web.php` - For web routes
- `routes/domain_api.php` - For API routes

Then add these lines to your main route files:

In `routes/web.php`:

```
require base_path('routes/domain_web.php');
```

In `routes/api.php`:

```
require base_path('routes/domain_api.php');
```

Domain Structure
----------------

[](#domain-structure)

This package supports two types of package structures:

### Composer Packages

[](#composer-packages)

```
packages/knausdev/package-name/
├── composer.json
├── src/
    ├── ...

```

### Domain Packages

[](#domain-packages)

```
domains/KnausDev/DomainName/
├── composer.json  # Automatically created to handle autoloading
├── Models/
├── Http/
├── ...

```

In domain packages, the namespace follows this structure:

- Domain: `KnausDev\DomainName`
- Controller: `KnausDev\DomainName\Http\Controllers\SomeController`

For example, a User domain would have the namespace `KnausDev\User\` and be located at `domains/KnausDev/User/`.

Each domain package automatically gets a `composer.json` file that configures PSR-4 autoloading for that domain. This autoloading is enabled by the Wikimedia Composer Merge Plugin, which is automatically configured when you run `php artisan knausdev:install`.

Field Types
-----------

[](#field-types)

The generator supports the following field types:

- `string` - String with customizable length
- `integer` - Integer with optional min/max values
- `text` - Text field with optional rich editor
- `boolean` - Boolean (true/false) values
- `float` - Decimal numbers with configurable precision
- `file` - File uploads with customizable validation

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

[](#contributing)

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

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1633895?v=4)[PeterK3](/maintainers/PeterK3)[@PeterK3](https://github.com/PeterK3)

---

Top Contributors

[![pknaus3](https://avatars.githubusercontent.com/u/47193837?v=4)](https://github.com/pknaus3 "pknaus3 (14 commits)")

### Embed Badge

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

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

###  Alternatives

[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

712181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)[laravel/pail

Easily delve into your Laravel application's log files directly from the command line.

91545.3M590](/packages/laravel-pail)

PHPackages © 2026

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