anandmainali/packagetemplate

使用包模板使包的开发更加容易。

dev-master 2020-05-30 10:55 UTC

This package is auto-updated.

Last update: 2024-09-29 05:29:40 UTC


README

Latest Version forks stars license Total Downloads

包模板可以帮助您通过单个命令创建包的结构。它还提供其他命令,就像在Laravel中生成文件一样。

安装

使用包管理器composer安装PackageTemplate。

composer require anandmainali/packagetemplate

启用包(可选)

此包实现了Laravel自动发现功能。安装后,包提供者和外观将自动添加到laravel >= 5.5。

配置

安装后,您需要发布配置文件。

php artisan vendor:publish --tag=package-config

这将生成config文件夹内的package.php文件。

Package.php

<?php

return [
  /**
   * Main folder to holds all the packages. Contains packages with VendorName. 
   */
  'path' => 'packages',
  
  /**
   * The VendorName will be generated inside the main folder.
   */
  'vendorName' => "VendorName",
  
  /**
   * These are the folders that will be generated while creating package.
   */
  'folders' => [
    'controllers', 'database/migrations', 'models', 'policies', 'resources/views', 'routes'
  ],
  
  /**
   * These are the files that will be generated while creating package.
   */
  'files' => ['routes/web']

];

现在,您可以开始构建您的包了。要生成包,

php artisan create:package 包名

然后,所有在config.php中指定的文件和文件夹都将生成。

使用php artisan的其他可用命令

注意: 包名用于在包内生成文件。

create:model ModelName PackageName
create:controller ControllerName PackageName --r //--r is optional. It is used to create resource controller.
create:migration MigrationName TableName PackageName
create:policy PolicyName PackageName
create:command CommandName --command=command:name PackageName