Php 钩住laravel 4 artisan命令
有没有一种方法可以轻松地钩住artisan命令?我希望在每次执行Php 钩住laravel 4 artisan命令,php,laravel,laravel-4,Php,Laravel,Laravel 4,有没有一种方法可以轻松地钩住artisan命令?我希望在每次执行php artisan migrate命令时都能执行一段代码。您可以扩展Schema Builder facade并覆盖构建函数,如下所示: protected function build(Blueprint $blueprint) { your_function(); Parent::build($blueprint); } 但是,在使用迁移的--佯装选项时,不会调用函数。我不知道有什么内置方法可以在不
php artisan migrate
命令时都能执行一段代码。您可以扩展Schema Builder facade并覆盖构建函数,如下所示:
protected function build(Blueprint $blueprint)
{
your_function();
Parent::build($blueprint);
}
但是,在使用迁移的--佯装选项时,不会调用函数。我不知道有什么内置方法可以在不扩展Schema Builder或Migrator类的情况下连接到迁移中。您可以扩展Schema Builder facade并覆盖构建函数,如下所示:
protected function build(Blueprint $blueprint)
{
your_function();
Parent::build($blueprint);
}
但是,在使用迁移的--佯装选项时,不会调用函数。我不知道有什么内置方法可以在不扩展Schema Builder或Migrator类的情况下连接到迁移中。只需在代码中的某个位置(甚至在app/start/artisan.php的顶部)添加一个侦听器,以侦听“artisan.start”事件
Event::listen('artisan.start', function($app)
{
// $app is instance of Illuminate\Console\Application
// since the $app hasn't figured the command yet you'll
// have to do it yourself to check if it's the migrate command
});
只需在代码中的某个位置(甚至在app/start/artisan.php的顶部)添加一个侦听器,以侦听“artisan.start”事件
Event::listen('artisan.start', function($app)
{
// $app is instance of Illuminate\Console\Application
// since the $app hasn't figured the command yet you'll
// have to do it yourself to check if it's the migrate command
});
您可以尝试以下方法(您可以将其放入
filters.php
文件中):
您可以尝试以下方法(您可以将其放入
filters.php
文件中):
您可以扩展或it调用。您可以扩展或it调用。