<?phpnamespace illuminate\cache\console;use illuminate\console\command;use illuminate\ Support\composer;use illuminate\filesystem\filesystem;// a namespace like folder ,so enoughclass cachetablecommand extends command{// a cache table Command a son class of father /** * The console command name. * * @var string */ protected $name = ' cache:table ';// the console command name. // a console command /** * The console command description. * * @var string */ protected $description = ' create a migration for The cache database table ';// a description // the console command description. /** * The filesystem instance. * * @var \ illuminate\filesystem\filesystem */ protected $files ;// the filesystem instance. /** * @ var \illuminate\support\composer */ protected $ composer;// a commposer instance /** * Create a new session table command instance. * * , @param \Illuminate\Filesystem\Filesystem $files * @param \Illuminate\Support\Composer $composer * @return void */ // create a new session table command instance. public function __construct ( filesystem $files, composer $composer) { parent::__construct ();// use parent construct function $this->files = $files;// a file to set $this->composer = $composer;// a composer instance } /** * execute the console command. * * @return void */ public function fire ()// fire like start,or run or execute the console command { $fullPath = $this->createbasemigration ();// create base Migration[move] $this->files->put ($fullPath, $ This->files->get (__dir__. ' /stubs/cache.stub '));// form the file cache to save the value to the table $this->info (' migration created successfully! '); / log info $this->composer->dumpautoloads ();// user composer api function . }&nbsP; /** * create a base migration file for the table. * * @return string */ protected function Createbasemigration ()// create a base migration file for the table. { $name = ' create_cache_table ';// a name create_cache_table $path = $this->laravel->databasepath (). ' /migrations ';// has a databasepath () return $this->laravel[' Migration.creator ']->create ($name, $path); }// a base full function}
This article is from the "Focus on PHP" blog, please be sure to keep this source http://lijinghsan.blog.51cto.com/3357095/1761166
Daily laravel-20160702| Cachetablecommand