每天laravel-20160702|CacheTableCommand

<?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
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值