@@ -2232,15 +2232,33 @@ exec ./configure "$@"
2232
2232
} )
2233
2233
log ( '🔧 ✅ Build-time PHP binary is working correctly' )
2234
2234
} catch ( error ) {
2235
- log ( '🔧 ❌ Build-time PHP binary still has issues, attempting additional fixes...' )
2235
+ log ( '💥 ❌ CRITICAL: Build-time PHP binary validation failed' )
2236
+ log ( '💥 This indicates a fundamental compilation issue that cannot be resolved with fallbacks' )
2236
2237
2237
2238
// Try additional comprehensive fixing
2238
2239
const otoolOutput = execSync ( `otool -L "${ buildTimePhpBinary } "` , { encoding : 'utf8' } )
2239
2240
log ( '🔧 Current dependencies after first fix:' )
2240
2241
log ( otoolOutput )
2241
2242
2242
2243
// Apply fixes again in case some were missed
2243
- fixMacOSLibraryPaths ( buildTimePhpBinary , homeDir )
2244
+ try {
2245
+ fixMacOSLibraryPaths ( buildTimePhpBinary , homeDir )
2246
+
2247
+ // Test the binary one more time after fixes
2248
+ execSync ( `"${ buildTimePhpBinary } " --version` , {
2249
+ stdio : 'pipe' ,
2250
+ env : {
2251
+ ...process . env ,
2252
+ DYLD_LIBRARY_PATH : libPaths . join ( ':' ) ,
2253
+ DYLD_FALLBACK_LIBRARY_PATH : libPaths . join ( ':' )
2254
+ }
2255
+ } )
2256
+ log ( '🔧 ✅ Build-time PHP binary fixed successfully' )
2257
+ } catch ( retryError ) {
2258
+ log ( '💥 ❌ CRITICAL: Build-time PHP binary cannot be fixed' )
2259
+ log ( '💥 This indicates a fundamental compilation failure' )
2260
+ throw new Error ( 'Build failed: PHP binary compilation produced non-functional binary despite fixes' )
2261
+ }
2244
2262
}
2245
2263
}
2246
2264
@@ -2307,12 +2325,27 @@ exec ./configure "$@"
2307
2325
timeout : 15 * 60 * 1000 , // 15 minutes timeout for install
2308
2326
} )
2309
2327
2310
- // Fallback: if make install didn't create the binary, manually copy it
2328
+ // Verify make install succeeded - it should have created the PHP binary
2311
2329
const phpBinaryPath = join ( installPrefix , 'bin' , 'php' )
2312
2330
const buildTimePhpBinary = join ( phpSourceDir , 'sapi' , 'cli' , 'php' )
2313
2331
2314
- if ( ! existsSync ( phpBinaryPath ) && existsSync ( buildTimePhpBinary ) ) {
2315
- log ( '🔧 ⚠️ make install did not create PHP binary, manually copying...' )
2332
+ if ( ! existsSync ( phpBinaryPath ) ) {
2333
+ log ( '💥 ❌ CRITICAL: make install failed to create PHP binary' )
2334
+ log ( `💥 Expected PHP binary at: ${ phpBinaryPath } ` )
2335
+ log ( `💥 Build-time binary exists: ${ existsSync ( buildTimePhpBinary ) } ` )
2336
+
2337
+ if ( existsSync ( buildTimePhpBinary ) ) {
2338
+ log ( '💥 This indicates make install failed during the installation phase' )
2339
+ log ( '💥 Check the make install logs above for errors' )
2340
+ } else {
2341
+ log ( '💥 This indicates make compilation failed to produce a working binary' )
2342
+ log ( '💥 Check the make logs above for compilation errors' )
2343
+ }
2344
+
2345
+ throw new Error ( 'Build failed: make install did not create PHP binary. This is a critical build failure.' )
2346
+ }
2347
+
2348
+ log ( '✅ make install successfully created PHP binary' )
2316
2349
2317
2350
// Copy the main PHP binary
2318
2351
copyFileSync ( buildTimePhpBinary , phpBinaryPath )
@@ -2414,6 +2447,54 @@ exec ./configure "$@"
2414
2447
}
2415
2448
}
2416
2449
2450
+ // Additional post-build validation
2451
+ log ( '🔍 Performing post-build validation...' )
2452
+
2453
+ // Verify final PHP binary works correctly
2454
+ try {
2455
+ const phpBinaryPath = join ( installPrefix , 'bin' , 'php' )
2456
+ const versionOutput = execSync ( `"${ phpBinaryPath } " --version` , {
2457
+ encoding : 'utf8' ,
2458
+ env : {
2459
+ ...process . env ,
2460
+ DYLD_LIBRARY_PATH : libPaths . join ( ':' ) ,
2461
+ DYLD_FALLBACK_LIBRARY_PATH : libPaths . join ( ':' )
2462
+ }
2463
+ } )
2464
+
2465
+ log ( '✅ Final PHP binary validation successful' )
2466
+ log ( `📋 PHP Version: ${ versionOutput . split ( '\n' ) [ 0 ] } ` )
2467
+
2468
+ // Check for required extensions
2469
+ const extensionsOutput = execSync ( `"${ phpBinaryPath } " -m` , {
2470
+ encoding : 'utf8' ,
2471
+ env : {
2472
+ ...process . env ,
2473
+ DYLD_LIBRARY_PATH : libPaths . join ( ':' ) ,
2474
+ DYLD_FALLBACK_LIBRARY_PATH : libPaths . join ( ':' )
2475
+ }
2476
+ } )
2477
+
2478
+ const extensions = extensionsOutput . split ( '\n' ) . filter ( ext => ext . trim ( ) )
2479
+ log ( `📦 Available extensions (${ extensions . length } ): ${ extensions . slice ( 0 , 10 ) . join ( ', ' ) } ${ extensions . length > 10 ? '...' : '' } ` )
2480
+
2481
+ // Check for critical extensions required for Laravel/Composer
2482
+ const criticalExtensions = [ 'Core' , 'json' , 'mbstring' , 'iconv' , 'openssl' , 'curl' ]
2483
+ const missingCritical = criticalExtensions . filter ( ext => ! extensions . includes ( ext ) )
2484
+
2485
+ if ( missingCritical . length > 0 ) {
2486
+ log ( `💥 ❌ CRITICAL: Missing required extensions: ${ missingCritical . join ( ', ' ) } ` )
2487
+ throw new Error ( `Build failed: Critical extensions missing: ${ missingCritical . join ( ', ' ) } ` )
2488
+ }
2489
+
2490
+ log ( '✅ All critical extensions present' )
2491
+
2492
+ } catch ( error ) {
2493
+ log ( '💥 ❌ CRITICAL: Final PHP binary validation failed' )
2494
+ log ( `💥 Error: ${ error } ` )
2495
+ throw new Error ( 'Build failed: Final PHP binary is not functional' )
2496
+ }
2497
+
2417
2498
// Fix library paths on macOS after installation
2418
2499
if ( config . platform === 'darwin' ) {
2419
2500
log ( '🔧 Fixing library paths for installed PHP binary...' )
0 commit comments