<?php namespace Illuminate\Cache\Console; use Illuminate\Console\Command; use Illuminate\Support\Composer; use Illuminate\Filesystem\Filesystem; // a namespace like folder ,so enough class 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 . } /** * 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 }
时间: 2024-10-12 12:14:51