這篇文章主要介紹了php中laravel框架自帶命令的實現方法,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
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實現
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 下面創建一個 down文件
touch($this->laravel->storagePath().'/framework/down');
$this->comment('Application is now in maintenance mode.');
}
}
// touch() 函數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中laravel框架自帶命令的實現方法”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業資訊頻道,更多相關知識等著你來學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。