您现在的位置是:课程教程文章
php laravel框架自带命令的实现
2023-12-14 22:16课程教程文章 人已围观
-
大数据之海量日志收集框架Flume,Source,Ch
大数据之海量日志收集框架Flume,Source,Ch往期课程录播视频/笔记和学习资料,请加璐璐老师QQ:2744886822 课程咨询加璐璐... -
WPF上位机通用框架平台实战【领取学习资
WPF上位机通用框架平台实战【领取学习资... -
LabVIEW机器视觉【通用框架篇】
LabVIEW机器视觉【通用框架篇】与其他平台完全不一样的讲解 含课程源码... -
【云知梦】CodeIgniter CI框架/PHP强大框架
【云知梦】CodeIgniter CI框架/PHP强大框架CodeIgniter是一个小巧但功能强大的PHP框架,作为一个简单而优雅的工具包,它可...
在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) {}
以上就是php laravel框架自带命令的实现,相信大家现在对于这种命令已经有所掌握,看完后跟着本篇的教程运行有关的代码即可。更多php学习指路:php框架
课程教程:php laravel框架自带命令的实现
上一篇:java中JVM运行时的内存整理
下一篇:没有了