@@ -3,10 +3,8 @@ package php
33import (
44 "bufio"
55 "context"
6- `errors`
7- `os`
6+ "os"
87 "os/signal"
9- `strings`
108 "syscall"
119 "time"
1210
@@ -41,14 +39,15 @@ type phpDevOptions struct {
4139}
4240
4341func runPHPDev (opts phpDevOptions ) error { // Result boundary
44- cwd , err := os .Getwd ()
45- if err != nil {
46- return core .E ("php" , "failed to get working directory" , err )
42+ cwdResult := core .Getwd ()
43+ if ! cwdResult . OK {
44+ return core .E ("php" , "failed to get working directory" , cwdResult . Value .( error ) )
4745 }
46+ cwd := cwdResult .Value .(string )
4847
4948 // Check if this is a Laravel project
5049 if ! IsLaravelProject (cwd ) {
51- return errors . New ( phpT ("cmd.php.error.not_laravel" ))
50+ return core . E ( "php" , phpT ("cmd.php.error.not_laravel" ), nil )
5251 }
5352
5453 cli .Print (cliLabelValueBlankFormat , dimStyle .Render (phpT (cmdPHPLabelKey )), phpT ("cmd.php.dev.starting" , map [string ]interface {}{"AppName" : laravelDisplayName (cwd )}))
@@ -182,13 +181,14 @@ func addPHPLogsCommand(c *core.Core, prefix string) {
182181}
183182
184183func runPHPLogs (service string , follow bool ) error { // Result boundary
185- cwd , err := os .Getwd ()
186- if err != nil {
187- return err
184+ cwdResult := core .Getwd ()
185+ if ! cwdResult . OK {
186+ return cwdResult . Value .( error )
188187 }
188+ cwd := cwdResult .Value .(string )
189189
190190 if ! IsLaravelProject (cwd ) {
191- return errors . New ( phpT ("cmd.php.error.not_laravel_short" ))
191+ return core . E ( "php" , phpT ("cmd.php.error.not_laravel_short" ), nil )
192192 }
193193
194194 // Create a minimal server just to access logs
@@ -232,10 +232,11 @@ func addPHPStopCommand(c *core.Core, prefix string) {
232232}
233233
234234func runPHPStop () error { // Result boundary
235- cwd , err := os .Getwd ()
236- if err != nil {
237- return err
235+ cwdResult := core .Getwd ()
236+ if ! cwdResult . OK {
237+ return cwdResult . Value .( error )
238238 }
239+ cwd := cwdResult .Value .(string )
239240
240241 cli .Print (cliLabelValueFormat , dimStyle .Render (phpT (cmdPHPLabelKey )), phpT ("cmd.php.stop.stopping" ))
241242
@@ -257,13 +258,14 @@ func addPHPStatusCommand(c *core.Core, prefix string) {
257258}
258259
259260func runPHPStatus () error { // Result boundary
260- cwd , err := os .Getwd ()
261- if err != nil {
262- return err
261+ cwdResult := core .Getwd ()
262+ if ! cwdResult . OK {
263+ return cwdResult . Value .( error )
263264 }
265+ cwd := cwdResult .Value .(string )
264266
265267 if ! IsLaravelProject (cwd ) {
266- return errors . New ( phpT ("cmd.php.error.not_laravel_short" ))
268+ return core . E ( "php" , phpT ("cmd.php.error.not_laravel_short" ), nil )
267269 }
268270
269271 appName := GetLaravelAppName (cwd )
@@ -314,10 +316,11 @@ func addPHPSSLCommand(c *core.Core, prefix string) {
314316}
315317
316318func runPHPSSL (domain string ) error { // Result boundary
317- cwd , err := os .Getwd ()
318- if err != nil {
319- return err
319+ cwdResult := core .Getwd ()
320+ if ! cwdResult . OK {
321+ return cwdResult . Value .( error )
320322 }
323+ cwd := cwdResult .Value .(string )
321324
322325 // Get domain from APP_URL if not specified
323326 if domain == "" {
@@ -336,7 +339,7 @@ func runPHPSSL(domain string) error { // Result boundary
336339 cli .Print (cliSingleLineFormat , phpT ("common.hint.install_with" ))
337340 cli .Print (" %s\n " , phpT ("cmd.php.ssl.install_macos" ))
338341 cli .Print (" %s\n " , phpT ("cmd.php.ssl.install_linux" ))
339- return errors . New ( phpT ("cmd.php.error.mkcert_not_installed" ))
342+ return core . E ( "php" , phpT ("cmd.php.error.mkcert_not_installed" ), nil )
340343 }
341344
342345 cli .Print (cliLabelValueFormat , dimStyle .Render ("SSL:" ), phpT ("cmd.php.ssl.setting_up" , map [string ]interface {}{"Domain" : domain }))
@@ -397,26 +400,26 @@ func printColoredLog(line string) {
397400 var style * cli.AnsiStyle
398401 serviceName := ""
399402
400- if strings .HasPrefix (line , "[FrankenPHP]" ) {
403+ if core .HasPrefix (line , "[FrankenPHP]" ) {
401404 style = phpFrankenPHPStyle
402405 serviceName = "FrankenPHP"
403- line = strings .TrimPrefix (line , "[FrankenPHP] " )
404- } else if strings .HasPrefix (line , "[Vite]" ) {
406+ line = core .TrimPrefix (line , "[FrankenPHP] " )
407+ } else if core .HasPrefix (line , "[Vite]" ) {
405408 style = phpViteStyle
406409 serviceName = "Vite"
407- line = strings .TrimPrefix (line , "[Vite] " )
408- } else if strings .HasPrefix (line , "[Horizon]" ) {
410+ line = core .TrimPrefix (line , "[Vite] " )
411+ } else if core .HasPrefix (line , "[Horizon]" ) {
409412 style = phpHorizonStyle
410413 serviceName = "Horizon"
411- line = strings .TrimPrefix (line , "[Horizon] " )
412- } else if strings .HasPrefix (line , "[Reverb]" ) {
414+ line = core .TrimPrefix (line , "[Horizon] " )
415+ } else if core .HasPrefix (line , "[Reverb]" ) {
413416 style = phpReverbStyle
414417 serviceName = "Reverb"
415- line = strings .TrimPrefix (line , "[Reverb] " )
416- } else if strings .HasPrefix (line , "[Redis]" ) {
418+ line = core .TrimPrefix (line , "[Reverb] " )
419+ } else if core .HasPrefix (line , "[Redis]" ) {
417420 style = phpRedisStyle
418421 serviceName = "Redis"
419- line = strings .TrimPrefix (line , "[Redis] " )
422+ line = core .TrimPrefix (line , "[Redis] " )
420423 } else {
421424 // Unknown service, print as-is
422425 cli .Print (cliLabelValueFormat , dimStyle .Render (timestamp ), line )
@@ -431,7 +434,7 @@ func printColoredLog(line string) {
431434}
432435
433436func getServiceStyle (name string ) * cli.AnsiStyle {
434- switch strings . ToLower (name ) {
437+ switch core . Lower (name ) {
435438 case "frankenphp" :
436439 return phpFrankenPHPStyle
437440 case "vite" :
0 commit comments