A Laravel package generator that streamlines the process of creating standardized package structures. Quickly bootstrap your packages with a complete, well-organized structure and focus on building functionality rather than configuration.

Features

  • Generates a complete Laravel package structure with a single command
  • Creates standard Laravel package directories (config, migrations, views, etc.)
  • Sets up composer.json with proper autoloading and dependencies
  • Creates a Service Provider with common Laravel integrations pre-configured
  • Includes testing setup with PHPUnit
  • Generates license, readme, and other essential files

Installation

You can install the package via composer:

composer require rayiumir/laravel-package

After Publish Config Files:

php artisan vendor:publish --provider="Rayiumir\LaravelPackage\ServiceProvider\PackageServiceProvider"

The service provider will be automatically registered for Laravel 5.5+. For older versions, add the service provider manually:

// config/app.php

'providers' => [
    Rayiumir\LaravelPackage\ServiceProvider\PackageServiceProvider::class,
];

Usage

Basic Usage

Generate a new package with the following command:

php artisan make:package my-package

This will create a new package in the packages/my-package directory with the default vendor name.
Customizing the Vendor Name

You can specify a custom vendor name:

php artisan make:package my-package --vendor=acme

Including Tests

To include PHPUnit test setup:

php artisan make:package my-package --with-tests

Generated Structure

The generated package will have the following structure:

packages/my-package/
├── config/
├── database/
│   └── migrations/
├── resources/
│   ├── lang/
│   └── views/
├── routes/
├── ServiceProvider/
│   └── PackageNameServiceProvider.php
├── tests/ (if --with-tests option is used)
│   ├── Feature/
│   ├── Unit/
│   └── TestCase.php
├── composer.json
├── LICENSE.md
├── README.md
└── phpunit.xml

Next Steps After Generation

After generating your package, you might want to:

  • Edit the composer.json file to update package details and requirements
  • Modify the Service Provider to add any specific functionality
  • Update the README.md with your package documentation
  • Add your migrations, routes, and views
  • Create your package's main classes in the src directory
  • If you used the --with-tests option, start writing tests for your package

Local Development

When developing the package locally within a Laravel application, you can add the repository to your application's composer.json:

"repositories": [
    {
        "type": "path",
        "url": "./packages/my-package"
    }
]

Testing Your Package

If you generated your package with the --with-tests option, you can run tests with:

cd packages/my-package
composer install
vendor/bin/phpunit