- How do I install and run laravel-packager to create a new Laravel package?
- Run `composer global require jeroen-g/laravel-packager` to install the CLI tool globally. Then generate a package with `laravel-package create vendor/package-name --template=default`. Ensure your Composer home directory is in your PATH for global commands to work.
- Does this tool support custom package templates (e.g., API-only or auth extensions)?
- Yes, the package includes template support. Use `--template=custom` to apply your own skeleton. Templates should follow Laravel’s PSR-4 and PSR-12 standards. You can also create reusable templates by extending the default structure in the tool’s configuration.
- Will laravel-packager work with Laravel 11 when it releases? Or is it tied to Laravel 10?
- The package is designed for Laravel 10+ and should support future versions, but check the release notes for updates. If Laravel 11 introduces breaking changes (e.g., package:discover updates), the tool will likely adapt. Monitor the GitHub repo for compatibility patches.
- Can I use this for packages that need dynamic namespace handling (e.g., multi-tenant apps)?
- Dynamic namespaces are supported but require manual configuration. Ensure your `autoload.psr-4` in `composer.json` aligns with your package’s namespace. For multi-tenant setups, extend the template to include conditional logic for namespace resolution during package registration.
- How does laravel-packager handle Facade conflicts if my package uses the same class name as another?
- The tool auto-generates Facade aliases in `config/app.php` but warns if conflicts exist. Resolve manually by editing the `aliases` array or renaming your Facade class. Always test with `composer why-not` to catch dependency issues early.
- Is this tool compatible with Laravel Forge or Vapor for deploying packages as microservices?
- Yes, the generated packages are Forge/Vapor-ready. Use multi-stage Docker builds to bake package scaffolding into your deployment images. Ensure your `composer.json` scripts (e.g., `post-install-cmd`) include package discovery commands if needed.
- What’s the best way to integrate this into CI/CD (e.g., GitHub Actions) for automated package generation?
- Add the CLI to your `composer.json` scripts under `post-create-project-cmd` or use a dedicated script in your workflow. Example: `composer global require jeroen-g/laravel-packager && laravel-package create vendor/package --template=api`. Test in a headless environment first.
- Are there alternatives to laravel-packager for Laravel package development?
- Yes, alternatives include `laravel/new` (basic scaffolding) or manual setup with `composer create-project --stability=dev`. However, laravel-packager offers deeper customization (templates, PSR-4 compliance) and Laravel-specific optimizations like Facade and Service Provider auto-registration.
- How do I handle legacy Laravel packages (<8.0) that need migration to this tool?
- For Laravel <8.0, manually adjust the generated `composer.json` to drop unsupported features (e.g., PHP 8.1+ syntax). Use polyfills if needed, but prioritize migrating to Laravel 10+ for full compatibility. Test incrementally with `composer validate` after generation.
- Does laravel-packager support publishing assets (views, configs) like Laravel’s `publishes` array?
- Yes, the tool includes support for the `publishes` array in `composer.json`. Generated packages will have placeholder entries for views, configs, and migrations. Customize the template to add your asset paths or use the `--publish` flag during creation.