for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the phpflo/phpflo package.
*
* (c) Henri Bergius <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PhpFlo\Component;
use PhpFlo\Component;
/**
* Class ReadFile
* @package PhpFlo\Component
* @author Henri Bergius <[email protected]>
class ReadFile extends Component
{
public function __construct()
$this->inPorts()->add('source', ['datatype' => 'string']);
$this->outPorts()
->add('out', ['datatype' => 'string'])
->add('error', []); // use defaults, datatype = all
$this->inPorts()->source->on('data', [$this, 'readFile']);
}
* @param string $data
public function readFile($data)
if (!file_exists($data)) {
$this->outPorts()->error->send("File {$data} doesn't exist");
return;
->out
->send(file_get_contents($data))
->disconnect();