Home>

Application scenario:analysis data (log)

php artisan make:console your command class name

Example:

php artisan make:console check

A check.php file has been generated in the \ app \ console \ commands directory

<?php
namespace app \ console \ commands;
use illuminate \ console \ command;
class check extends command
{
  /**
   * the name and signature of the console command.
   *
   * @var string
   * /
  protected $signature="command: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 ()
  {
    //
  }
}

You can change $signature to the name of the command i want

protected $signature="check";

It cannot be called in the console at this time,Need to register in kernel.php.

protected $commands=[
    "app \ console \ commands \ check"
];

You can already use this command in the console

php artisan check

Comments:It seems useless,Because PHP itself can also use the cli command line without the laravel framework.

php
  • Previous vue20 multi-criteria search component use in detail
  • Next Routing and Controller of Homemade PHP Framework