当我尝试从 deploy.php 的闭包中调用 artisan 函数时,我遇到了这个错误:
[Error] Call to undefined function Deployer\artisan()
我的 deploy.php 看起来像这样:
<?php declare(strict_types=1);
namespace Deployer;
require 'recipe/laravel.php';
require 'recipe/rsync.php';
// ...
$migrateClosure = function () {
artisan('migrate:fresh --force')();
};
// ...
task('migrate', $migrateClosure);
$deployTasks = [];
$deployTasks[] = 'deploy:info';
$deployTasks[] = 'deploy:prepare';
$deployTasks[] = 'deploy:lock';
$deployTasks[] = 'deploy:release';
$deployTasks[] = 'rsync'; // Deploy code & built assets
$deployTasks[] = 'deploy:secrets';
$deployTasks[] = 'deploy:shared';
$deployTasks[] = 'deploy:vendors';
$deployTasks[] = 'deploy:writable';
$deployTasks[] = 'artisan:storage:link';
$deployTasks[] = 'artisan:view:cache';
$deployTasks[] = 'artisan:config:cache';
$deployTasks[] = 'artisan:optimize';
$deployTasks[] = 'migrate';
$deployTasks[] = 'deploy:symlink';
$deployTasks[] = 'deploy:unlock';
$deployTasks[] = 'cleanup';
task('deploy', $deployTasks);
问题是;怎么可能(如果可能的话)调用在 ?artisan
中声明的函数recipe/laravel.php
?