1. Running the command line in Windows 10 throws an error: Call to undefined function App\Console\Commands\posix_getpid(). See Figure 1.

PS E:\wwwroot\msi_main> php artisan migrate
In ExportRecords.php line 65:
Call to undefined function App\Console\Commands\posix_getpid()
2. Reference URL: https://www.php.net/manual/zh/intro.posix.php . This extension is not available on Windows platforms. You can also try using getmypid() instead. See Figure 2.

3. posix_getpid — Returns the current process ID. Decided to replace it with: getmypid — Gets PHP’s process ID. Reference URL: https://www.php.net/getmypid.
4. Edit /app/Console/Commands/ExportRecords.php. Replace posix_getpid with getmypid.
private function setLogPrefix() {
// $pid = posix_getpid();
$pid = getmypid();
$ppid = posix_getppid(); //获取父进程id
$this->log_prefix = "CommandExportRecords : pid:{$pid} : ppid:{$ppid} :";
return $this;
}
5. Continue running the command line, and an error is thrown: Call to undefined function App\Console\Commands\posix_getppid().
PS E:\wwwroot\msi_main> php artisan migrate
In ExportRecords.php line 67:
Call to undefined function App\Console\Commands\posix_getppid()
6. posix_getppid does not work on Windows. This is an alternative solution. Reference URL: https://www.php.net/manual/zh/function.posix-getppid . Check if it is a Windows system; if so, use the alternative solution. See Figure 3.

private function setLogPrefix() {
if(strncasecmp(PHP_OS, "win", 3) == 0) {
$pid = getmypid(); // child process ID
$ppid = shell_exec("wmic process where (processid=$pid) get parentprocessid");
$ppid = explode("\n", $ppid);
$ppid = intval($ppid[1]);
} else {
$pid = posix_getpid();
$ppid = posix_getppid(); //获取父进程id
}
$this->log_prefix = "CommandExportRecords : pid:{$pid} : ppid:{$ppid} :";
return $this;
}
7. Continue running the command line, and no further errors occur. See Figure 4.

PS E:\wwwroot\msi_main> php artisan migrate
Migration table created successfully.
