溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

php中l(wèi)aravel框架自帶命令的實現(xiàn)方法

發(fā)布時間:2021-04-29 10:07:18 來源:億速云 閱讀:111 作者:小新 欄目:編程語言

這篇文章主要介紹了php中l(wèi)aravel框架自帶命令的實現(xiàn)方法,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

python有哪些常用庫

python常用的庫:1.requesuts;2.scrapy;3.pillow;4.twisted;5.numpy;6.matplotlib;7.pygama;8.ipyhton等。

1、作為服務提供者,加載到程序中。

// config/app.php 中。
'providers' => [
    // 這個便是laravel自帶的artisan命令提供者
    Illuminate\Foundation\Providers\ArtisanServiceProvider::class,
]

2、然后找到 Up/Down命令入口

/**
 * Register the command.
 *
 * @return void
 */
protected function registerUpCommand()
{
    $this->app->singleton('command.up', function () {
        return new UpCommand;
    });
}

3、DownCommand實現(xiàn)

class DownCommand extends Command
{
    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'down';
 
    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Put the application into maintenance mode';
 
    /**
     * Execute the console command.
     *
     * @return void
     */
    public function fire()
    {
        // 關鍵點: 在當前存儲目錄/framework 下面創(chuàng)建一個 down文件
        touch($this->laravel->storagePath().'/framework/down');
 
        $this->comment('Application is now in maintenance mode.');
    }
}
 
 
// touch() 函數(shù)php文檔解釋
/**
 * Sets access and modification time of file
 * @link http://php.net/manual/en/function.touch.php
 * @param string $filename <p>
 * The name of the file being touched.
 * </p>
 * @param int $time [optional] <p>
 * The touch time. If time is not supplied,
 * the current system time is used.
 * </p>
 * @param int $atime [optional] <p>
 * If present, the access time of the given filename is set to
 * the value of atime. Otherwise, it is set to
 * time.
 * </p>
 * @return bool true on success or false on failure.
 * @since 4.0
 * @since 5.0
 */
function touch ($filename, $time = null, $atime = null) {}

感謝你能夠認真閱讀完這篇文章,希望小編分享的“php中l(wèi)aravel框架自帶命令的實現(xiàn)方法”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業(yè)資訊頻道,更多相關知識等著你來學習!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內容。

AI