jackiedo / laravel-packager
一个用于创建 Laravel 应用程序包的 CLI 工具。
Requires
- php: >=5.4.0
- illuminate/console: ^5.1|^6.0|^7.0|^8.0|^9.0|^10.0
- illuminate/filesystem: ^5.1|^6.0|^7.0|^8.0|^9.0|^10.0
- illuminate/support: ^5.1|^6.0|^7.0|^8.0|^9.0|^10.0
- jackiedo/path-helper: ^1.0
README
此包是一个 CLI 工具,可以帮助您快速构建 Laravel 应用程序的完整结构化包。
您不再需要为您的包手动初始化骨架。相反,专注于编写源代码,让 Laravel Packager 负责包结构的组织。
功能
- 为包构建目录结构。
- 为包生成标准的 composer.json 文件。
- 为包生成标准的 Service Provider 文件。
- 为包生成一些基本资源,如:Facade、Interface、Abstract、Trait、Exception、Controller、Middleware、Model、Artisan Command、Config、Migration、Language、View、Route、Helper...
- 允许将创建的包作为本地仓库安装和使用。
版本和兼容性
此包与 Laravel 5.1 及以上版本兼容。然而,由该包生成的骨架资源与 Laravel 5.0 及以上版本兼容。
概述
查看以下主题之一,了解更多关于 Laravel Packager 的信息
安装
您可以通过以下步骤使用 Composer 安装 Laravel Packager。
需求包
在应用程序目录的根目录下运行以下命令
$ composer require jackiedo/laravel-packager
注意:从 Laravel 5.5 开始,服务提供者和别名自动注册,您不需要做更多操作。但如果您使用 Laravel 5.4 或更早版本,您必须执行以下额外步骤。
注册服务提供者
打开 config/app.php
,并在 providers
部分添加新行
Jackiedo\Packager\PackagerServiceProvider::class,
用法
1. 创建新的包
用法:
$ php artisan packager:new [options] [--] <name>
参数和选项:
Arguments:
name The name (<vendor>/<project>) of the package.
Options:
--author-name[=AUTHOR-NAME] Author name.
--author-email[=AUTHOR-EMAIL] Author email.
--description[=DESCRIPTION] Package description.
--keywords[=KEYWORDS] Package keywords.
--license[=LICENSE] License of package.
--homepage[=HOMEPAGE] Package homepage.
-r, --resources Request to create package with advanced resources.
-i, --install Request to install package after creation.
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output,
2 for more verbose output and 3 for debug
示例:
- 使用高级资源创建
jackiedo/first-demo
包
$ php artisan packager:new jackiedo/first-demo --resources
- 创建
jackiedo/second-demo
包并在创建后安装
$ php artisan packager:new jackiedo/second-demo --install
注意:
- 所有包都将放置在 Laravel 应用程序基础路径的
packages
目录中。 - 如果您在命令中不使用
--install
选项,您可以在以后使用 composer 命令composer require your/project
安装您的包。这在您想在安装之前开发完整的源代码时非常有用。
2. 列出所有包
用法:
$ php artisan packager:list
3. 注销现有包
默认情况下,当创建包时,它将自动注册到 Laravel 的 composer.json
文件中的仓库部分。这允许您将包作为本地仓库安装。如果出于任何原因您想取消此注册,请使用以下命令
用法:
$ php artisan packager:unregister [options] [--] <name>
参数和选项:
Arguments:
name The name (<vendor>/<project>) of the package.
Options:
-u, --uninstall Request to uninstall package before perform unregister.
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output,
2 for more verbose output and 3 for debug
示例:注销 jackiedo/first-demo
包
$ php artisan packager:unregister jackiedo/first-demo
注意:
- 如果包之前已安装,您需要运行命令
composer remove your/project
来先卸载它,或者在使用packager:unregister
命令时使用--uninstall
选项。 - 一旦注销,除非再次注册,否则无法安装包。
4. 注册现有包
在从composer.json
文件的存储库部分取消注册现有包后,如果您想再次注册它,请使用以下命令
用法:
$ php artisan packager:register <name>
参数和选项:
Arguments:
name The name (<vendor>/<project>) of the package.
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output,
2 for more verbose output and 3 for debug
5. 删除现有包
用法:
$ php artisan packager:remove [options] [--] <name>
参数和选项:
Arguments:
name The name (<vendor>/<project>) of the package.
Options:
-u, --uninstall Request to uninstall package before removing.
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output,
2 for more verbose output and 3 for debug
示例:
$ php artisan packger:remove jackiedo/first-demo --uninstall
配置
如果您想设置更高级的设置,例如骨架结构、建议等,您需要使用以下vendor:publish
命令发布配置文件:
$ php artisan vendor:publish --provider="Jackiedo\Packager\PackagerServiceProvider" --tag="config"
注意:在设置任何设置之前,请仔细阅读配置文件中的说明。
其他文档
有关包开发的更多文档,您可以访问官方Laravel文档页面
许可
MIT © Jackie Do