Weave 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

Lpackager Laravel Package

amranidev/lpackager

Lpackager is a Laravel package scaffolding tool that generates boilerplate and structure for reusable packages, helping you set up service providers, configuration, routes, and resources faster. It gives you a starting point for building and distributing Laravel packages with less manual setup.

View on GitHub
Deep Wiki
Context7

Getting Started

amranidev/lpackager is a workbench-style scaffolding generator: it writes a Laravel package skeleton into a packages/ directory at the root of your app so you can develop a package in-place, then extract it later. It is not a runtime dependency — treat it as a dev tool.

1. Install (dev-only):

composer require --dev amranidev/lpackager

On Laravel 5.5+ the service provider is auto-discovered. On older versions add Amranidev\Lpackager\LpackagerServiceProvider::class to config/app.php.

2. Look here first:

  • php artisan list — filter for the package's commands (they are prefixed packager: in most versions). Confirm the exact signatures your installed version exposes before scripting anything; the CLI surface changed across releases and the README on GitHub tracks master, not necessarily the 2018-11-04 tag you'd get from Composer.
  • config/lpackager.php (publish with php artisan vendor:publish if it isn't there) — controls where packages are generated and the default namespace/vendor used by the prompt defaults.
  • The generated skeleton itself: packages/<vendor>/<name>/{src,composer.json,README.md}. Read the generated composer.json and service provider before writing code — that's the contract everything else hangs off.

3. First use case. The fastest way to see the value is to pull one self-contained slice out of an app — a "Blog" module with a model, migration, routes, and views:

php artisan packager:new Acme Blog

You'll be prompted for vendor, package name, author, and description. Then wire the new namespace into the root autoloader:

"autoload": {
    "psr-4": {
        "Acme\\Blog\\": "packages/acme/blog/src"
    }
}
composer dump-autoload

If the skeleton's composer.json does not include extra.laravel.providers, register the generated BlogServiceProvider manually in config/app.php — don't assume auto-discovery applies to a package that lives in packages/ rather than vendor/.

Implementation Patterns

Scaffold → iterate → extract. The intended loop is: generate into packages/, build and test the feature there while the host app uses it via the PSR-4 mapping, then either keep it as a path dependency or move it to its own repo and composer require it for real. Keep the packages/ tree in the app's git history while iterating; only .gitignore it once the package is published and pinned by version.

Path repository for proper dependency semantics. Once the package has its own composer.json, prefer a path repo over hand-edited PSR-4 so the package's own require block actually resolves:

"repositories": [{ "type": "path", "url": "packages/acme/blog" }],
"require": { "acme/blog": "*" }

This catches namespace and autoload mistakes early, because Composer validates them instead of relying on your root mapping.

Let the generator own the boilerplate, you own the wiring. Generated providers typically register config, routes, migrations, and views with the usual loadViewsFrom/loadMigrationsFrom/mergeConfigFrom calls and a __DIR__.'/../routes/web.php' path. Verify each of those paths points where you think it does after any rename, and keep routes namespaced (Route::namespace('Acme\Blog\Http\Controllers')->group(...)) so package routes don't collide with app routes.

Use the migrate helper for iteration speed. Running package migrations straight from the tool (packager:migrate, vendor/package arguments) avoids the copy-into-database/migrations dance during development. The moment you're happy with the schema, switch to loadMigrationsFrom in the provider and let the host app's php artisan migrate handle it — that's the behaviour you want in downstream installs.

Duplicate for multi-tenant or variant packages. When you need a second package that's 90% the same (e.g. Blog and News), generate from an existing skeleton rather than from scratch, then do a global find-and-replace on namespace and on any hardcoded package name strings. Do this before writing feature code; renaming after the fact is where most time is lost.

Test the generated package in isolation. Add orchestra/testbench to the generated package and run its own PHPUnit suite there. A package that only works when mounted in the host app isn't ready to be extracted — the whole point of the tool is portability.

Gotchas and Tips

  • It's dormant. Last release was November 2018, 42 stars, and the ecosystem has moved through Laravel 6/7/8/9/10 LTS boundaries since. Expect incompatibilities above Laravel 5.8: removed string/array helpers, the str_slug removal, and provider auto-discovery nuances. Pin your Laravel version or budget time to patch the generator. For new projects, weigh laravel-packager or Laravel's own php artisan package-workbench patterns as alternatives.
  • Forgetting composer dump-autoload is the #1 "class not found" cause. Every generate, rename, or namespace change needs it. If a class still won't resolve, check the generated composer.json psr-4 key against the actual directory casing — PSR-4 is case-sensitive on Linux and silently forgiving on macOS, so it'll break in CI only.
  • Don't assume generated code matches your app's conventions. Templates are frozen in ~2018 style. After generating, immediately align the provider, routes, and migration stubs to your app's current idioms before you have a hundred lines to retrofit.
  • Duplicate/rename leaves stale references. The generator copies files; it does not reliably rewrite every namespace occurrence (composer.json, provider $namespace, route controller strings, view namespace in loadViewsFrom, migration class names). After any duplication, grep -ri "<oldname>" packages/ and fix by hand.
  • Config publishing vs. editing vendor. If you need to change the target directory or defaults, publish config/lpackager.php and edit the published copy — changes inside vendor/amranidev/lpackager disappear on the next composer update.
  • View namespacing. Generated views are loaded under the package's short name, so they must be referenced as view('package::path') from the host app. If your views render blank, that's usually a missing double-colon or a loadViewsFrom path one directory off.
  • Migrating out of the workbench. When you extract the package to its own repo, delete the root psr-4 mapping and the packages/ entry in the same commit, then composer dump-autoload -o. Leaving both in place gives you two copies of the same class and a confusing "which one is loaded" bug.
  • Extension point worth knowing: the generator's stubs are the natural place to inject your own house style (strict types, your base TestCase, your CI config). Forking the package or overriding its views/stubs is usually cheaper than post-processing generated files on every run.
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.
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle