magento 常會需要建立很多檔案

光是一個 hello world 就要建立三、四個資料夾、七、八個檔案

開發過程會常需要複製舊程式來修改

這時若有辦法快速生成這些檔案  開發過程將會方便許多

 

pastle 是一個可以快速生成 magento 程式的代碼生成工具

利用 pastle 建立 hello world 只需要三行即可解決

後續會再介紹

 

magento2:generate:module

magento2:generate:route  

magento2:generate:view  

magento2:generate:command   

magento2:generate:di    

......等相關 generate 指令

 

pestle.phar 檔案下載

 

安裝方式很簡單

在專案目錄下輸入語法

 

curl -LO http://pestle.pulsestorm.net/pestle.phar

 

待 100% 檔案下載完成即可

 

在專案目錄下多了一個 pestle.phar 的檔案

查詢可用指令

 

下載完成後 輸入語法

 

php pestle.phar list-commands

即列出可用的語法及簡單說明

 



 

安裝完成後 即可使用 pestle 的語法

 

使用方式就是直接在 commend line 上輸入語法

語法格式 php pestle command_name [options] [arguments]

command_name 就如 list-commands 所顯示

 

個人覺得 Magento2 Generate 語法有幾個還滿方便、好用的功能

可以快速的生成檔案,不需要再複製貼上

後續將繼續介紹常用到的 Magento2 Generate 語法

 

參考來源 : https://github.com/astorm/pestle

相關文章