-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
973 PHP Web Server Action for built-in app development
- Adds the PHP Dev-Test Web Server Action to serve the application. This has the feature of abiding by the "Quiet" flags at different levels. I haven't seen any other built-in PHP Web Server [Yii, Laravel]. Minor feature. - Removed "-" from CLI Text action, it was confusing - TStdOutWriter. This fopens 'php://stdout' when processing a web page b/c STDOUT is not available. - Corrected TOutputWriter to write to the output rather than stdout. - Added README.md text for starting the PHP Web Server Action after installing the application.
- Loading branch information
Showing
11 changed files
with
638 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
/** | ||
* TStdOutWriter class file | ||
* | ||
* @author Brad Anderson <belisoful@icloud.com> | ||
* @link https://github.com/pradosoft/prado | ||
* @license https://github.com/pradosoft/prado/blob/master/LICENSE | ||
*/ | ||
|
||
namespace Prado\IO; | ||
|
||
/** | ||
* TStdOutWriter class. | ||
* | ||
* TStdOutWriter extends TTextWriter to fwrite the buffer to STDOUT when {@see flush}ed. | ||
* This allows for testing of the Shell output. | ||
* | ||
* STDOUT is only defined in the CLI. When processing a PHP web page, this opens | ||
* a new handle to 'php://stdout'. | ||
* | ||
* @author Brad Anderson <belisoful@icloud.com> | ||
* @since 4.2.3 | ||
*/ | ||
class TStdOutWriter extends TTextWriter | ||
{ | ||
/** The file path to open a data stream in memory */ | ||
public const STDOUT_URI = 'php://stdout'; | ||
|
||
/** @var mixed the Standard Out stream handle */ | ||
private mixed $_stdout; | ||
|
||
/** | ||
* Closes the StdOut handle when STDOUT is not defined | ||
*/ | ||
public function __destruct() | ||
{ | ||
if (!defined('STDOUT') && $this->_stdout) { | ||
fclose($this->_stdout); | ||
} | ||
parent::__destruct(); | ||
} | ||
|
||
/** | ||
* Flushes the content that has been written. | ||
* @return string the content being flushed | ||
*/ | ||
public function flush() | ||
{ | ||
$str = parent::flush(); | ||
|
||
if (!$this->_stdout) { | ||
if (!defined('STDOUT')) { | ||
$this->_stdout = fopen(TStdOutWriter::STDOUT_URI, 'wb'); | ||
} else { | ||
$this->_stdout = STDOUT; | ||
} | ||
} | ||
|
||
fwrite($this->_stdout, $str); | ||
flush(); | ||
|
||
return $str; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.