Questions tagged [runkit]

PECL runkit extension

Runkit extension for PHP

For all those things you.... probably shouldn't have been doing anyway....

The Runkit extension is designed to allow you to change a PHP function definition at runtime. Both user-defined and internal functions can be redefined.

This behaviour is known as 'Monkey patching'. It is not considered a good coding practice, and should be avoided for general use. It is occasionally useful in test scripts, but not in production code.

Download up-to-date versions from http://github.com/zenovich/runkit

35 questions
5
votes
2 answers

PHP - Alternatives to runkit for intercepting method calls

I have some very test-unfriendly code (to say the least) that I need to test. Refactoring unfortunately is not an option. I have to test the code as it is, without the possibility of changing it. To do that, I was thinking of intercepting function…
rid
  • 61,078
  • 31
  • 152
  • 193
3
votes
1 answer

PHPUnit setUp to run for an individual test with dataProvider

I have a PHPUnit test testFoo() with a dataProvider fooProvider(). At the beginning of testFoo() I'm using Runkit to redefine a method so I can test expected results when that method is returning what I've redefined it to return. However, redefining…
thanksd
  • 54,176
  • 22
  • 157
  • 150
2
votes
0 answers

Execute user request in a runkit sandbox session

I have an environment where users upload php projects, something similar to that for a shared hosting. User's code will have nothing to do with Runkit. Their code has to be executed in my runkit environment. Is it possible to have a Request handler…
Vishnu
  • 21
  • 5
2
votes
2 answers

Can someone compile PHP runkit DLL extension for me?

I give up. I've asked this question some time ago but I'm again into that issue. I'm still stuck with compilation errors / missing files / other stuff that I can't / don't have time to fix. Don't get me wrong - I've compiled it several times, but…
Tomasz Kowalczyk
  • 10,472
  • 6
  • 52
  • 68
2
votes
1 answer

Is it possible to style RunKit?

Are there any possible ways to customize the styling of RunKit (https://runkit.com)? Like make the background of the editor to dark theme. I tried injecting styles to the RunKit iframe but it does not work. Looking for any suggestions or any…
2
votes
1 answer

Where can I get runkit DLL extensions for PHP 5.3+?

That is a quick question: Where can I get PHP's runkit extension for version 5.3+? Manual for it: http://php.net/manual/en/book.runkit.php I am searching for DLL version, as I am trying to play with it on Windows. I've searched snaps.php.net,…
Tomasz Kowalczyk
  • 10,472
  • 6
  • 52
  • 68
2
votes
1 answer

embedding multiple RunKit REPL instances on a single web page

I am creating a web-based presentation using RemarkJS, my preferred tool for presentations. Since I want to demo small bits of nodejs code, I want to use RunKit's REPL embedding capability. I couldn't quite figure out how to embed multiple instances…
punkish
  • 13,598
  • 26
  • 66
  • 101
2
votes
0 answers

RunKit samples for react native not working

Does anyone know why the samples (contacts) in RunKit are not working? I tried various samples around contacts and all have syntax error. https://runkit.com/npm/react-native-paged-contacts https://runkit.com/npm/react-native-contacts-android Thanks,
EyalS
  • 1,530
  • 2
  • 11
  • 25
2
votes
1 answer

External request in Runkit endpoint

Runkit (https://runkit.com), has a service where you can publish endpoints. I am looking to publish an enpoint that calls an external server for data, and returns that data. It seems as though I am unable to accomplish this. Here's what I've…
user2202911
  • 2,898
  • 5
  • 20
  • 28
2
votes
0 answers

Runkit Sandbox: use parent's class instances?

The following code... function getInstance() { echo "(getInstance() called)\n"; return new TestClass(); } class TestClass { function someMethod() { echo "someMethod called. Awesome!\n"; } } $sandbox = new…
Udo G
  • 12,572
  • 13
  • 56
  • 89
2
votes
1 answer

How to rename or overwrite php function?

How i can redefine a function in php with runkit? $helloWorld = 'echo "Call require_once";'; runkit_function_redefine('require_once', '$word', $helloWorld); require_once("abc.php"); i seted in php.ini runkit.internal_override=1 when i run, it…
Mr Jerry
  • 1,686
  • 3
  • 14
  • 22
1
vote
1 answer

Runkit - No 'Access-Control-Allow-Origin' header is present on the requested resource

var cors = require("cors"); cors({ origin: '*' }); cors({ allowHeaders: 'X-PINGOTHER'}); cors({ methods: 'GET,HEAD,PUT,PATCH,POST,DELETE'}); exports.endpoint = function(request, response) { let text = '100,000'; response.writeHead(200, {…
blazk
  • 5
  • 2
1
vote
2 answers

Fix: Use global instead of window

I am trying a component inside runkit.com. As it is visible from the image, the platform tells me ... Fix: Use global instead of window. RunKit is a node environment, so window and other browser features won’t exist. If you’re just trying to…
sensorario
  • 20,262
  • 30
  • 97
  • 159
1
vote
0 answers

Runkit can't redefine static method

I have this class class DateTimeHelper { public static function getDateTimeNow() { return new \DateTime('now'); } } And I want in tests redefine output to date that I want: So I do: $r = runkit_method_redefine( …
zajca
  • 2,288
  • 4
  • 30
  • 40
1
vote
0 answers

remove non-user constant php

I'm trying to remove the STDIN constant for debugging purposes, however phpdbg> ev runkit_constant_remove('STDIN') [PHP Warning: runkit_constant_remove(): Only user defined constants may be removed. in eval()'d code on line 1] So I would like to…
timwaagh
  • 303
  • 3
  • 14
1
2 3