關於網路那些事...

網路行銷,SEO,網路趨勢,教學文章,網頁設計,生活時事

Lumen 擴充 generator

Lumen 主旨在建立一個快速微服務框架

在預設的功能中,僅保留少數 laravel 原生功能項目

舉例來說,Lumen 不提供 artisan make:controller

因此,在建立 controller 時候需要手動方式生成

在 controller 裏已經有準備好 controller.php 讓你方便複製

這裡則是要介紹,如何透過擴充 lumen generator ,將 laravel 多數 command 能在 lumen 中使用

安裝 lumen-generator

composer require flipbox/lumen-generator

設定

開啟 bootstrap/app.php 並且新增:

$app->register(Flipbox\LumenGenerator\LumenGeneratorServiceProvider::class);

可使用的 command

key:generate      Set the application key

make:command      Create a new Artisan command
make:controller   Create a new controller class
make:event        Create a new event class
make:job          Create a new job class
make:listener     Create a new event listener class
make:mail         Create a new email class
make:middleware   Create a new middleware class
make:migration    Create a new migration file
make:model        Create a new Eloquent model class
make:policy       Create a new policy class
make:provider     Create a new service provider class
make:seeder       Create a new seeder class
make:test         Create a new test class

附加功能

clear-compiled    Remove the compiled class file
serve             Serve the application on the PHP development server
tinker            Interact with your application
optimize          Optimize the framework for better performance
route:list        Display all registered routes.

底下是 tinker 使用範例

$environment = app()->environment();
$output = new Symfony\Component\Console\Output\ConsoleOutput();
$output->writeln("<info>Hello the app environment is `{$environment}`</info>");
$output->writeln("<comment>Did something</comment>");
$output->writeln("<error>Did something bad</error>");

如果這篇文章對你有幫助,請在這裡點個讚



最新文章推薦