有人详解下命令行stub吗? 
                            
                                                    
                        
                    
                    
  
                    
                    目前写的
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class Service extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'make:service {name}';
    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';
    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }
    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $name = $this->argument('name');
        $service_name = $name . 'Service';
        $dir = 'app/Services';
        if (!(is_dir($dir) && file_exists($dir))) {
            mkdir($dir, 0777, true);
        }
        $str = <<<STR
<?php
namespace App\Services;
class {$service_name}  {
}
STR;
        try{
            if (!file_exists($service_name)) {
                $fp = fopen($dir . '/' . $service_name . '.php', 'w');
                fwrite($fp, $str);
            }
        }catch(\Exception $e) {
            $this->info('创建失败');return;
        }
        $this->info("create {$service_name} successfully");
    }
} 
           
         
             
                     
                     
             
             
           
           关于 LearnKu
                关于 LearnKu
               
                     
                     
                     粤公网安备 44030502004330号
 粤公网安备 44030502004330号 
 
推荐文章: