Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/Commands/StartFrankenPhpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class StartFrankenPhpCommand extends Command implements SignalableCommandInterfa
Concerns\InteractsWithEnvironmentVariables,
Concerns\InteractsWithServers {
Concerns\InteractsWithServers::writeServerRunningMessage as baseWriteServerRunningMessage;
Concerns\InteractsWithServers::startServerWatcher as baseStartServerWatcher;
}

/**
Expand Down Expand Up @@ -192,12 +193,17 @@ protected function buildMercureConfig()
}

/**
* Always return a no-op object, because FrankenPHP has native watcher support.
* Use the regular watcher when --poll is passed (e.g. for network file systems).
* Otherwise use FrankenPHP's built-in watcher.
*
* @return object
* @return \Symfony\Component\Process\Process|object
*/
protected function startServerWatcher()
{
if ($this->option('poll') && $this->option('watch')) {
return $this->baseStartServerWatcher();
}

return new class
{
public function __call($method, $parameters)
Expand All @@ -209,12 +215,13 @@ public function __call($method, $parameters)

/**
* Generate the file watcher configuration snippet to include in the Caddyfile.
* When --poll is passed, the regular watcher is used instead, so no Caddy config.
*
* @return string
*/
protected function buildWatchConfig()
{
if (! $this->option('watch')) {
if (! $this->option('watch') || $this->option('poll')) {
return '';
}

Expand Down