Download the PHP package trd-rdm/make-unit-command without Composer
On this page you can find all versions of the php package trd-rdm/make-unit-command. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download trd-rdm/make-unit-command
More information about trd-rdm/make-unit-command
Files in trd-rdm/make-unit-command
Package make-unit-command
Short Description A laravel make command to help project team members easily create project files for a route.
License MIT
Informations about the package make-unit-command
Unit Make Command
用法
Introduction
A laravel unit make command which may help project team member quickly create the necessary files for a resource route.
1. 安裝步驟
(1) 安裝
打開命令提示視窗,在專案根目錄路徑底下輸入 composer require trd-rdm/make-unit-command --dev
確認安裝成功後
(2) 註冊 Service Provider
在專案根目錄下找到 app/Providers/AppServiceProvider.php 中找到 register() 函式 在函式中 宣告只有在本地端 (當APP_ENV = local) 才註冊 UnitCommandServiceProvider,添加內容如下斜線粗體部分:
說明: 只在本地端註冊避免在 google cloud platform 上建置機器時,可能會無法連線到此 私人GitLab函式庫而導致建立過程出錯,同時建置機器時建議以"composer install --no-dev" 安裝,跳過安裝 require-dev 中的開發階段的套件,避免建置失敗。
(3) 複製套件文檔至專案中
打開命令提示視窗,在專案根目錄路徑底下輸入 php artisan vendor:publish --tag=generator --force,將必要檔案複製到專案中,若是沒有顯示錯誤,表示安裝完成。 不要忘了將這些檔案 git add,push 上 server 讓專案成員可以使用。
2. 使用說明:
(1) 指令
用法類似於 Laravel 內建的 make:controller的指令。
打開命令提示視窗,在專案根目錄路徑底下輸入,在專案根目錄底下輸入 php artisan make:unit Folder/User ,表示在 Folder 資料夾底下建立相關文件。
上述指令會
(1) 在 app/Http/Folder/Controller/User底下建立 Controller.php, Transform.php, Form.php
(2) 在App/Management/Folder/User 底下建立 Service.php, SearchService.php, Repository.php, Entity.php
(3) 在 api.php 底下新增預設的 resource routes 如下:
- 特別注意的是程式會自動檢測 URI 格式重複的 route 不會被建立,例如若是 api.php 中已經有Route::put('user/{id}, ...),為了避免路由覆蓋的問題,Route::put('user/{user}', 'User\Controller@update') 將不會被建立。
(2) 啟用/停用建立檔案
若是不想自動在 api.php 底下新增 resource routes,可以到config/generator.php 底下找到'route' 將 enable 改為 false。 同理,你也可以disable controller, entity 或是 search 檔案的建立。
3. 更新步驟:
指令
- composer update rdm/make-unit-command
- 在專案根目錄路徑底下輸入 php artisan vendor:publish --tag=generator --force 覆蓋舊檔案
-
將所有變更 git push
v1.1.0
2019-10-14
Added
- 在 controller 添加 transformer 以及 Search 類別的宣告
- 添加輸入參數字首是否為大寫的檢查,若是小寫會詢問。
Changed
- 修正 command help 描述
- 修改 shell 輸出訊息顏色
v1.1.1
2019-12-30
Added
- 添加 Form::attributes() 以讓程式人員可以自定義驗證錯誤訊息中的驗證欄位名稱
Changed
- 修正改 Form::authorize() 中範例呼叫的權限函式配合新版 Basic_Project 從 BaseForm::permission(tag, value) 改成 BaseForm::can(value, tag) 以增加程式可讀性
並且 BaseForm::can() 支援 Closure 格式的呼叫
v1.1.2
2020-04-09
Changed
- 修正 MAC / Linux 環境下不支援 backslash 路徑導致的創建檔案問題
v1.1.5
2022-01-10
Changed
- 修正替換 Laravel 8 已經棄用的 Str 輔助函式
Form 範例程式
Form.php
格式自由填寫