@@ -84,35 +84,16 @@ export type PHPRequestHandlerFactoryArgs = PHPFactoryOptions & {
8484 requestHandler : PHPRequestHandler ;
8585} ;
8686
87- export type PHPRequestHandlerConfiguration = BaseConfiguration &
88- (
89- | {
90- /**
91- * PHPProcessManager is required because the request handler needs
92- * to make a decision for each request.
93- *
94- * Static assets are served using the primary PHP's filesystem, even
95- * when serving 100 static files concurrently. No new PHP interpreter
96- * is ever created as there's no need for it.
97- *
98- * Dynamic PHP requests, however, require grabbing an available PHP
99- * interpreter, and that's where the PHPProcessManager comes in.
100- */
101- processManager : PHPProcessManager ;
102- }
103- | {
104- phpFactory : (
105- requestHandler : PHPRequestHandlerFactoryArgs
106- ) => Promise < PHP > ;
107- /**
108- * The maximum number of PHP instances that can exist at
109- * the same time.
110- */
111- maxPhpInstances ?: number ;
112- }
113- ) & {
114- cookieStore ?: CookieStore | false ;
115- } ;
87+ export type PHPRequestHandlerConfiguration = BaseConfiguration & {
88+ phpFactory : ( requestHandler : PHPRequestHandlerFactoryArgs ) => Promise < PHP > ;
89+ /**
90+ * The maximum number of PHP instances that can exist at
91+ * the same time.
92+ */
93+ maxPhpInstances ?: number ;
94+
95+ cookieStore ?: CookieStore | false ;
96+ } ;
11697
11798/**
11899 * Handles HTTP requests using PHP runtime as a backend.
@@ -202,29 +183,25 @@ export class PHPRequestHandler implements AsyncDisposable {
202183 getFileNotFoundAction = ( ) => ( { type : '404' } ) ,
203184 } = config ;
204185
205- if ( 'processManager' in config ) {
206- this . processManager = config . processManager ;
207- } else {
208- this . processManager = new PHPProcessManager ( {
209- phpFactory : async ( info ) => {
210- const php = await config . phpFactory ! ( {
211- ...info ,
212- requestHandler : this ,
213- } ) ;
214-
215- // Always set managed PHP's cwd to the document root.
216- if ( ! php . isDir ( documentRoot ) ) {
217- php . mkdir ( documentRoot ) ;
218- }
219- php . chdir ( documentRoot ) ;
220-
221- // @TODO : Decouple PHP and request handler
222- ( php as any ) . requestHandler = this ;
223- return php ;
224- } ,
225- maxPhpInstances : config . maxPhpInstances ,
226- } ) ;
227- }
186+ this . processManager = new PHPProcessManager ( {
187+ phpFactory : async ( info ) => {
188+ const php = await config . phpFactory ! ( {
189+ ...info ,
190+ requestHandler : this ,
191+ } ) ;
192+
193+ // Always set managed PHP's cwd to the document root.
194+ if ( ! php . isDir ( documentRoot ) ) {
195+ php . mkdir ( documentRoot ) ;
196+ }
197+ php . chdir ( documentRoot ) ;
198+
199+ // @TODO : Decouple PHP and request handler
200+ ( php as any ) . requestHandler = this ;
201+ return php ;
202+ } ,
203+ maxPhpInstances : config . maxPhpInstances ,
204+ } ) ;
228205
229206 /**
230207 * By default, config.cookieStore is undefined, so we use the
@@ -245,8 +222,8 @@ export class PHPRequestHandler implements AsyncDisposable {
245222 this . #PORT = url . port
246223 ? Number ( url . port )
247224 : url . protocol === 'https:'
248- ? 443
249- : 80 ;
225+ ? 443
226+ : 80 ;
250227 this . #PROTOCOL = ( url . protocol || '' ) . replace ( ':' , '' ) ;
251228 const isNonStandardPort = this . #PORT !== 443 && this . #PORT !== 80 ;
252229 this . #HOST = [
0 commit comments