У меня есть контроллер:
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct(){}
public function index()
{
pcntl_fork();
}
}
Затем я вызываю index()
по HTTP-запросу, и я получаю:
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Call to undefined function App\Http\Controllers\pcntl_fork()
Затем я пытаюсь это:
class CodeSheet extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'code_sheet';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
pcntl_fork();
echo "1\n";
}
}
Затем я вызываю эту команду:
vagrant@homestead:~$ php artisan code_sheet
1
1
Итак, мой вопрос: почему я могу вызвать pcntl_fork()
в команде, но не могу в HTTP-запросе?