Skip to content

Commit d83c3a2

Browse files
committed
chore: wip
1 parent bfcfe25 commit d83c3a2

File tree

1 file changed

+102
-7
lines changed

1 file changed

+102
-7
lines changed

scripts/build-php.ts

Lines changed: 102 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,6 @@ async function downloadWindowsPhpBinary(config: BuildConfig): Promise<string> {
167167
stdio: 'inherit'
168168
})
169169

170-
// Create comprehensive php.ini with all available extensions
171-
log('Creating comprehensive php.ini for Windows PHP...')
172-
createWindowsPhpIni(installPrefix)
173-
174170
// Ensure php.exe is in the bin directory
175171
const phpExePath = join(phpSourceDir, 'php.exe')
176172
const targetPhpExePath = join(installPrefix, 'bin', 'php.exe')
@@ -182,8 +178,8 @@ async function downloadWindowsPhpBinary(config: BuildConfig): Promise<string> {
182178
}
183179

184180
// Create comprehensive php.ini that enables all available extensions
185-
await createWindowsPhpIni(installPrefix)
186-
181+
log('Creating comprehensive php.ini for Windows PHP...')
182+
createWindowsPhpIni(installPrefix, config)
187183
log('✅ Created comprehensive php.ini with all available extensions enabled')
188184

189185
// If we downloaded a different version than requested, update the metadata
@@ -401,7 +397,7 @@ function generateCIConfigureArgs(config: BuildConfig, installPrefix: string): st
401397
return ciArgs
402398
}
403399

404-
function createWindowsPhpIni(phpDir: string): void {
400+
function createWindowsPhpIni(phpDir: string, config: BuildConfig): void {
405401
const extDir = join(phpDir, 'ext')
406402
const mainDir = phpDir
407403

@@ -680,6 +676,100 @@ openssl.capath =
680676
writeFileSync(join(phpDir, 'php.ini'), phpIniContent)
681677
}
682678

679+
function createUnixPhpIni(installPrefix: string, config: BuildConfig): void {
680+
const phpIniPath = join(installPrefix, 'lib', 'php.ini')
681+
682+
// Create comprehensive php.ini content for Unix builds
683+
const phpIniContent = `; PHP Configuration File
684+
; Generated automatically for Launchpad PHP build (Unix)
685+
686+
[PHP]
687+
; Basic settings
688+
engine = On
689+
short_open_tag = Off
690+
precision = 14
691+
output_buffering = 4096
692+
zlib.output_compression = Off
693+
implicit_flush = Off
694+
unserialize_callback_func =
695+
serialize_precision = -1
696+
disable_functions =
697+
disable_classes =
698+
zend.enable_gc = On
699+
zend.exception_ignore_args = On
700+
zend.exception_string_param_max_len = 0
701+
702+
; Resource Limits
703+
max_execution_time = 30
704+
max_input_time = 60
705+
memory_limit = 128M
706+
707+
; Error handling and logging
708+
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
709+
display_errors = Off
710+
display_startup_errors = Off
711+
log_errors = On
712+
ignore_repeated_errors = Off
713+
ignore_repeated_source = Off
714+
report_memleaks = On
715+
716+
; Data Handling
717+
variables_order = "GPCS"
718+
request_order = "GP"
719+
register_argc_argv = Off
720+
auto_globals_jit = On
721+
post_max_size = 8M
722+
auto_prepend_file =
723+
auto_append_file =
724+
default_mimetype = "text/html"
725+
default_charset = "UTF-8"
726+
727+
; File Uploads
728+
file_uploads = On
729+
upload_max_filesize = 2M
730+
max_file_uploads = 20
731+
732+
; Extensions
733+
; Let PHP auto-detect the extension directory
734+
; extension_dir will be set automatically by PHP
735+
736+
; Zend Extensions (must be loaded first)
737+
; Use full path to ensure OPcache loads correctly
738+
zend_extension=opcache.so
739+
740+
; OPcache Configuration
741+
opcache.enable=1
742+
opcache.enable_cli=1
743+
opcache.memory_consumption=128
744+
opcache.interned_strings_buffer=8
745+
opcache.max_accelerated_files=4000
746+
opcache.revalidate_freq=2
747+
opcache.fast_shutdown=1
748+
opcache.save_comments=1
749+
opcache.enable_file_override=0
750+
opcache.validate_timestamps=1
751+
opcache.jit_buffer_size=100M
752+
opcache.jit=tracing
753+
754+
; Phar
755+
phar.readonly = Off
756+
phar.require_hash = On
757+
758+
; OpenSSL
759+
openssl.cafile =
760+
openssl.capath =
761+
`
762+
763+
writeFileSync(phpIniPath, phpIniContent)
764+
765+
// Also create a copy in the etc directory if it exists
766+
const etcPhpIniPath = join(installPrefix, 'etc', 'php.ini')
767+
const etcDir = join(installPrefix, 'etc')
768+
if (existsSync(etcDir)) {
769+
writeFileSync(etcPhpIniPath, phpIniContent)
770+
}
771+
}
772+
683773
async function buildPhp(config: BuildConfig): Promise<string> {
684774
const installPrefix = join(config.outputDir, `php-${config.phpVersion}-${config.platform}-${config.arch}-${config.config}`)
685775

@@ -949,6 +1039,11 @@ exec "$@"
9491039
env: buildEnv
9501040
})
9511041

1042+
// Create php.ini for Unix builds to enable OPcache and other extensions
1043+
log('Creating php.ini for Unix PHP build...')
1044+
createUnixPhpIni(installPrefix, config)
1045+
log('✅ Created php.ini with OPcache and extensions enabled')
1046+
9521047
// Create metadata file
9531048
const metadata = {
9541049
php_version: config.phpVersion,

0 commit comments

Comments
 (0)