I'm trying to write a custom wrapper in PHP using the Stream Wrapper class. What I have now is pretty much simple and straight forward.
class Stream
{
public $resource;
public static function wrap()
{
stream_wrapper_unregister(self::PROTOCOL);
stream_wrapper_register(self::PROTOCOL, __CLASS__);
}
public static function unwrap ( )
{
stream_wrapper_restore(self::PROTOCOL);
}
public function stream_open ( $path, $mode, $options, &$openedPath )
{
$this->unwrap();
// Open memory
$this->resource = fopen('php://memory', 'rb+');
$code = file_get_contents ( $path );
// Write code to memory
fwrite($this->resource, $code);
rewind($this->resource);
$this->wrap();
return $this->resource !== false;
}
// Left out the other methods that the stream wrapper needs
// to keep this example simple
// ...
}
In the beginning of my code I open the stream by calling: Stream::wrap()
.
Then it basically reads any file that is require
'ed or include
'ed throughout my application. The code is then put into php://memory
and that's it. Nothing special yet.
Bottom line is, is that this piece of code should work. But it throws an Internal Server Error when I try to run my application. I have a Linux hosting provider (PHP 5.4.21) where my code is currently hosted.
But when I move my code from my current hoster to some other Linux hosting company (PHP 5.5.x), then everything works fine.
When I even move the code to my local computer (PHP 5.4.6) and run it, then everything works fine as well.
So obviously the problem lies at the hosting company that I currently have. I know I have to mail them. But I have no clue what is causing the problem exactly. It would be good if I could at least point them in a certain direction. All I have now is
my code isn't working on your servers which is working fine on some other server
I'm afraind that that isn't enough information for them.
I have checked the php://memory
limit which is set to 256M. That should be more than enough. So I have no clue what else to look for. The Apache log didn't had any information either.
So I was hoping anyone here had an idea of what could be causing this problem. Perhaps some permission issue somewhere or something?