Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Package Helper Laravel Package

zero-to-prod/package-helper

Laravel package that helps you scaffold and manage reusable PHP/Laravel packages faster. Provides handy helpers and sensible defaults to streamline setup, development workflows, and publishing assets/config so you can go from zero to production quickly.

View on GitHub
Deep Wiki
Context7

Getting Started

Start by installing the package via Composer into your package’s development dependencies:

composer require --dev zero-to-prod/package-helper

Then, in your package’s main service provider (e.g., YourPackageServiceProvider), extend the provided base class instead of ServiceProvider:

use ZeroToProdPackageHelper\ServiceProvider;

class YourPackageServiceProvider extends ServiceProvider
{
    protected $configPath = __DIR__.'/../config/your-package.php';
    protected $migrationsPath = __DIR__.'/../database/migrations';
    protected $viewsPath = __DIR__.'/../resources/views';
}

The first use case is simple: scaffolding a new package with zero boilerplate—just extend the class, define paths, and publish() calls for config/migrations/views happen automatically on php artisan vendor:publish.

Implementation Patterns

  • Consistent Publishing: Call $this->publishesConfig(), $this->publishesMigrations(), and $this->publishesViews() in boot()—no repetitive publishes() arrays needed.
  • Auto-Register Commands: Use $this->registerCommands([YourCommand::class]) to register multiple Artisan commands cleanly.
  • Environment-Aware Boot: Override configureEnvironment() to apply defaults (e.g., fallback config values) conditionally per environment.
  • Laravel Octane Ready: The base service provider avoids static state and side effects—safe for request reuse.
  • Package Builder Workflows: Integrate with tools like laravel-packager or custom scripts to generate boilerplate via vendor:publish --tag=your-package-config.

Gotchas and Tips

  • Config Path Must Exist: publishesConfig() throws a runtime error if the config file doesn’t exist—ensure it’s present before first publish (e.g., include a stub in config/your-package.php).
  • Migrations Register Only Once: The helper automatically deduplicates migration paths—safe to call publishesMigrations() in multiple service providers (e.g., core + optional features).
  • Extend, Don’t Override: Prefer overriding methods like register() / boot() after calling parent::register() / parent::boot(). The base class handles resource registration in the correct order.
  • Tagging is Optional: Don’t use $this->publishes*() without vendor:publish—by design, nothing is auto-registered to config/app.php unless explicitly requested. Users must explicitly publish to customize.
  • Check for app()->runningInConsole(): If you need command-specific logic in your provider, guard it with if ($this->app->runningInConsole()) { ... }—though most helpers already do this internally.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport