Introducing the make:package Command for Laravel #55328
Replies: 6 comments 20 replies
-
What are the benefits over https://spatie.be/courses/laravel-package-training-v2/starting-a-laravel-package-using-the-skeleton |
Beta Was this translation helpful? Give feedback.
-
I created the package, take a look. |
Beta Was this translation helpful? Give feedback.
-
I would assume this to make more sense as a new command of the Laravel installer |
Beta Was this translation helpful? Give feedback.
-
its a good idea, this helps developers to create better and same struct for packages, im so exited about this issue |
Beta Was this translation helpful? Give feedback.
-
Can this new command also automatically brew a cup of coffee? Because with all this automation, we should be able to enjoy the finer things in life too!:) |
Beta Was this translation helpful? Give feedback.
-
This idea seems to be well received. Example of the following command:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The goal of this proposal is to introduce a new Artisan command make:package to Laravel. This command will automatically generate the necessary structure and files for a Laravel package, And this makes it easier for developers.
The make:package command will allow developers to generate the a new package with a single command, avoiding the need to manually create directories and files for common elements of a Laravel package.
Features:
Directory Structure: The command will generate a set of standard directories, including.
src/
: Contains the PHP source code for the package.config/
: For configuration files.resources/
: For views, translations, etc.routes/
: For defining package routes.Files Generated:
composer.json
: Automatically generates a Composer file, including PSR-4 autoloading for the package.README.md
: Provides a basic readme file with the package name and description.Command Syntax:
Example:
This command will create the following structure in the
packages/{vendor}/
directory:Why This Feature:
Creating reusable packages in Laravel is a common task for many developers, especially when working on large applications or multi-project systems. However, setting up the basic structure for a package can be tedious and error-prone, especially when you need to create multiple packages. By adding this command, Laravel would streamline the process and help developers focus more on their package logic rather than setup.
How it Works:
The command accepts the package name as an argument and creates a new folder with the specified name.
It generates a default
composer.json
file with PSR-4 autoloading configured for thesrc/
directory.It creates a basic
README.md
file with the package name and a description.Additional directories like
config/
,resources/
, androutes/
are created to follow Laravel’s typical package structure.Example Use Case:
Imagine a scenario where a developer needs to create multiple packages for different features in their Laravel project. Instead of manually setting up each package’s file structure, they can simply run:
Each command will create the necessary files and folders for the respective package, saving time and ensuring consistency across all packages.
Conclusion:
The
make:package
Artisan command will improve the developer experience by simplifying the process of creating reusable Laravel packages. It would promote best practices for package structure and help maintain consistency in package development. This feature will be especially beneficial for large projects that require multiple packages, reducing setup time and potential errors.I’d love to hear your thoughts on this and would be happy to open a Pull Request if this sounds like a feature worth including in the core.
Thanks and best regards!
Beta Was this translation helpful? Give feedback.
All reactions