diff --git a/src/Illuminate/Foundation/Console/FormatCommand.php b/src/Illuminate/Foundation/Console/FormatCommand.php new file mode 100644 index 000000000000..d3fdffe0ba5e --- /dev/null +++ b/src/Illuminate/Foundation/Console/FormatCommand.php @@ -0,0 +1,79 @@ +option('test')) { + $command[] = '--test'; + } + + if ($this->option('dirty')) { + $command[] = '--dirty'; + } + + $path = $this->argument('path'); + if ($path) { + $command[] = $path; + } + + $process = new Process($command); + $process->setTimeout(null); + + if (Process::isTtySupported()) { + $process->setTty(true); + } + + $process->run(); + + return 0; + } catch (Exception $e) { + $this->components->error(sprintf( + 'Failed to format the application: %s.', + $e->getMessage(), + )); + + return 1; + } + } +} diff --git a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php index 4ec8289653d7..61c9a560b041 100755 --- a/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php +++ b/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php @@ -53,6 +53,7 @@ use Illuminate\Foundation\Console\EventListCommand; use Illuminate\Foundation\Console\EventMakeCommand; use Illuminate\Foundation\Console\ExceptionMakeCommand; +use Illuminate\Foundation\Console\FormatCommand; use Illuminate\Foundation\Console\InterfaceMakeCommand; use Illuminate\Foundation\Console\JobMakeCommand; use Illuminate\Foundation\Console\KeyGenerateCommand; @@ -222,6 +223,7 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid 'TraitMake' => TraitMakeCommand::class, 'VendorPublish' => VendorPublishCommand::class, 'ViewMake' => ViewMakeCommand::class, + 'Format' => FormatCommand::class, ]; /**