@@ -31,8 +31,7 @@ function shouldMigrateDatabase(store) {
31
31
}
32
32
33
33
function shouldOptimize ( store ) {
34
- return store . get ( 'optimized_version' ) !== app . getVersion ( )
35
- && process . env . NODE_ENV !== 'development' ;
34
+ return store . get ( 'optimized_version' ) !== app . getVersion ( ) ;
36
35
}
37
36
38
37
async function getPhpPort ( ) {
@@ -253,7 +252,7 @@ function getDefaultEnvironmentVariables(secret, apiPort): EnvironmentVariables {
253
252
} ;
254
253
255
254
// Only add cache paths if in production mode
256
- if ( runningSecureBuild ( ) ) {
255
+ if ( runningSecureBuild ( ) ) {
257
256
variables . APP_SERVICES_CACHE = join ( bootstrapCache , 'services.php' ) ;
258
257
variables . APP_PACKAGES_CACHE = join ( bootstrapCache , 'packages.php' ) ;
259
258
variables . APP_CONFIG_CACHE = join ( bootstrapCache , 'config.php' ) ;
@@ -296,6 +295,7 @@ function serveApp(secret, apiPort, phpIniSettings): Promise<ProcessResult> {
296
295
// Make sure the storage path is linked - as people can move the app around, we
297
296
// need to run this every time the app starts
298
297
if ( ! runningSecureBuild ( ) ) {
298
+ console . log ( 'Linking storage path...' ) ;
299
299
callPhpSync ( [ 'artisan' , 'storage:link' , '--force' ] , phpOptions , phpIniSettings )
300
300
}
301
301
@@ -333,33 +333,38 @@ function serveApp(secret, apiPort, phpIniSettings): Promise<ProcessResult> {
333
333
const phpPort = await getPhpPort ( ) ;
334
334
335
335
336
- let serverPath = join ( appPath , 'build' , '__nativephp_app_bundle' ) ;
336
+ let serverPath : string ;
337
+ let cwd : string ;
337
338
338
- if ( ! runningSecureBuild ( ) ) {
339
+ if ( runningSecureBuild ( ) ) {
340
+ serverPath = join ( appPath , 'build' , '__nativephp_app_bundle' ) ;
341
+ } else {
339
342
console . log ( '* * * Running from source * * *' ) ;
340
343
serverPath = join ( appPath , 'vendor' , 'laravel' , 'framework' , 'src' , 'Illuminate' , 'Foundation' , 'resources' , 'server.php' ) ;
344
+ cwd = join ( appPath , 'public' ) ;
341
345
}
342
346
343
347
const phpServer = callPhp ( [ '-S' , `127.0.0.1:${ phpPort } ` , serverPath ] , {
344
- cwd : join ( appPath , 'public' ) ,
348
+ cwd : cwd ,
345
349
env
346
350
} , phpIniSettings )
347
351
348
352
const portRegex = / D e v e l o p m e n t S e r v e r \( .* : ( [ 0 - 9 ] + ) \) s t a r t e d / gm
349
353
354
+ // Show urls called
350
355
phpServer . stdout . on ( 'data' , ( data ) => {
351
356
// [Tue Jan 14 19:51:00 2025] 127.0.0.1:52779 [POST] URI: /_native/api/events
352
357
353
358
if ( parseInt ( process . env . SHELL_VERBOSITY ) > 0 ) {
354
- console . log ( data . toString ( ) ) ;
359
+ console . log ( data . toString ( ) . trim ( ) ) ;
355
360
}
356
361
} )
357
362
358
-
363
+ // Show PHP errors and indicate which port the server is running on
359
364
phpServer . stderr . on ( 'data' , ( data ) => {
360
365
const error = data . toString ( ) ;
361
366
const match = portRegex . exec ( data . toString ( ) ) ;
362
- // console.log('E:', error);
367
+
363
368
if ( match ) {
364
369
const port = parseInt ( match [ 1 ] ) ;
365
370
console . log ( "PHP Server started on port: " , port ) ;
@@ -368,23 +373,25 @@ function serveApp(secret, apiPort, phpIniSettings): Promise<ProcessResult> {
368
373
process : phpServer ,
369
374
} ) ;
370
375
} else {
371
-
372
- // Starting at [NATIVE_EXCEPTION]:
373
376
if ( error . includes ( '[NATIVE_EXCEPTION]:' ) ) {
377
+ let logFile = join ( storagePath , 'logs' , 'laravel.log' ) ;
378
+
374
379
console . log ( ) ;
375
380
console . error ( 'Error in PHP:' ) ;
376
381
console . error ( ' ' + error . split ( '[NATIVE_EXCEPTION]:' ) [ 1 ] . trim ( ) ) ;
377
382
console . log ( 'Please check your log file:' ) ;
378
- console . log ( ' ' + join ( appPath , 'storage' , 'logs' , 'laravel.log' ) ) ;
383
+ console . log ( ' ' + logFile ) ;
379
384
console . log ( ) ;
380
385
}
381
386
}
382
387
} ) ;
383
388
389
+ // Log when any error occurs (not started, not killed, couldn't send message, etc)
384
390
phpServer . on ( 'error' , ( error ) => {
385
391
reject ( error )
386
392
} ) ;
387
393
394
+ // Log when the PHP server exits
388
395
phpServer . on ( 'close' , ( code ) => {
389
396
console . log ( `PHP server exited with code ${ code } ` ) ;
390
397
} ) ;
0 commit comments