php laravel框架自带命令的实现
Admin 2022-09-30 群英技术资讯 713 次浏览
这篇文章主要讲解了“php laravel框架自带命令的实现”,文中的讲解内容简单、清晰、详细,对大家学习或是工作可能会有一定的帮助,希望大家阅读完这篇文章能有所收获。下面就请大家跟着小编的思路一起来学习一下吧。在PHP的框架学习中,我们已经对laravel的安装和配置有所掌握,那么除此之外,在该框架中有一种自带命令,不知道小伙伴们有没有在使用的时候留意过呢?之前没有接触过artisan的也不要着急,本篇就laravel框架自带命令会带来使用的步骤介绍,一起来看看接下来的命令实现吧。
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) {}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
laravel gulp出错的解决办法:1、打开终端命令窗口;2、通过执行“$ npm rebuild node-sass”命令即可解决Gulp命令出错问题。
php输出形式实例整理,php中有5种输出形式,分别是echo、print_r、print、var_dump和die。
本篇文章给大家带来了关于Laravel请求声明周期的相关知识,请求生命周期有不同的术语,如自动加载器、内核、服务提供器、调度请求和路由等,希望对大家有帮助。
其中,Redis常见的报错就是:Redis可以配置如果客户端经过多少秒还不给Redis服务器发送数据,那么就会把连接close掉;MySQL常见的报错:和Redis服务器一样,MySQL也会定时的去清理掉没用的连接。
今天小编就为大家分享一篇关于laravel-admin ueditor 集成并解决刷新的问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008