@@ -23,7 +23,10 @@ protected function configure()
2323 ->setDescription ('Run your Leaf app ' )
2424 ->addArgument ('filename ' , InputArgument::OPTIONAL , 'The PHP script to run ' )
2525 ->addOption ('port ' , 'p ' , InputOption::VALUE_OPTIONAL , 'Port to run app on ' )
26- ->addOption ('watch ' , 'w ' , InputOption::VALUE_NONE , 'Run your leaf app with hot reloading [experimental] ' );
26+ ->addOption ('watch ' , 'w ' , InputOption::VALUE_NONE , 'Run your leaf app with hot reloading [experimental] ' )
27+ // ->addOption('path', 't', InputOption::VALUE_OPTIONAL, 'Path to your app', getcwd() . '/public')
28+ // ->addOption('host', 's', InputOption::VALUE_OPTIONAL, 'Your application host', 'localhost')
29+ ->addOption ('no-concurrent ' , 'nc ' , InputOption::VALUE_OPTIONAL , 'Run PHP server without Vite server ' , false );
2730 }
2831
2932 protected function execute (InputInterface $ input , OutputInterface $ output ): int
@@ -111,10 +114,20 @@ protected function askToInstallWatcher($input, $output)
111114
112115 protected function startServer (InputInterface $ input , OutputInterface $ output ): int
113116 {
114- $ port = $ input ->getOption ('port ' ) ? (int ) $ input ->getOption ('port ' ) : 5500 ;
117+ $ useConcurrent = true ;
118+
119+ $ noConcurrent = $ input ->getOption ('no-concurrent ' );
120+ $ port = (int ) ($ input ->getOption ('port ' ) ?? 5500 );
121+
122+ if ($ noConcurrent || !file_exists (getcwd () . '/vite.config.js ' )) {
123+ $ useConcurrent = false ;
124+ }
125+
126+ $ serveCommand = !$ useConcurrent ? "php -S localhost: $ port " : "npx concurrently -c \"#3eaf7c,#bd34fe \" \"php -S localhost: $ port \" \"npm run dev \" --names=server,vite --colors " ;
127+
115128 $ isDockerProject = file_exists (getcwd () . '/docker-compose.yml ' );
116129 $ process = Process::fromShellCommandline (
117- $ isDockerProject ? 'docker compose up ' : " php -S localhost: $ port " ,
130+ $ isDockerProject ? 'docker compose up ' : $ serveCommand ,
118131 null ,
119132 null ,
120133 null ,
0 commit comments