- How do I quickly scaffold a Laravel package with all the boilerplate files?
- Run `php artisan package:make YourPackageName` in your Laravel project. This generates a complete package structure with folders for src/, config/, tests/, and a ready-to-register Service Provider, along with Composer and Laravel conventions.
- Does this package support custom templates for different package types (e.g., API packages, CLI tools)?
- Yes, use the `--template` flag to specify a custom template. For example, `php artisan package:make MyApiPackage --template=api-package`. You can also create your own templates in the `templates/` directory for team-specific needs.
- Which Laravel versions are officially supported by this package?
- The package is tested and optimized for Laravel 8.x and 9.x. For Laravel 7, you may need to use the `--force` flag and manually adjust paths in the generated config files, as some Laravel 8+ features are assumed.
- Will this package generate tests and PHPStan/Pest configurations by default?
- Yes, it includes a `tests/` directory with basic test files and pre-configures PHPStan, Pest, and Laravel Pint for modern PHP workflows. This ensures your package is ready for static analysis and testing out of the box.
- Can I use this package in a non-Laravel PHP project (e.g., Symfony, Slim)?
- No, this package is specifically designed for Laravel and assumes Laravel’s service provider, facade, and publisher patterns. It won’t work with non-Laravel PHP frameworks like Symfony or Slim.
- How do I handle conflicts with `laravel/package-tools` if it’s auto-included?
- If you encounter conflicts, you can either exclude it during generation or manually merge configurations post-generation. For production packages, consider using the `--no-dev` flag to avoid including unnecessary dependencies.
- Does this package enforce PSR-12 or other coding standards?
- The generated package includes Laravel Pint and PHPStan configurations by default, which enforce PSR-12 and other modern PHP standards. You can customize these in the template or post-generation.
- How can I integrate this into a CI/CD pipeline for package validation?
- Add a GitHub Action or pre-commit hook to validate the package structure. For example, create a workflow that runs `php artisan package:validate YourPackage` to ensure consistency before merging.
- What if I need a package structure that deviates from Laravel conventions?
- You can extend the default templates or create custom ones. For example, add a `--namespace` flag to override default namespaces or use post-generation scripts to modify files as needed.
- Are there alternatives to this package for scaffolding Laravel packages?
- Yes, alternatives include manually creating the structure or using tools like `laravel/new` for basic scaffolding. However, **backtheweb/laravel-package-maker** is tailored specifically for reusable Laravel packages with built-in conventions, testing, and tooling support.