diff --git a/doc/creating-a-language-target.md b/doc/creating-a-language-target.md index 365a091539..723b865f2c 100644 --- a/doc/creating-a-language-target.md +++ b/doc/creating-a-language-target.md @@ -68,3 +68,14 @@ Run the script from `runtime-tests` dir with ``` or whatever your test grammar, start rule, target, test input are. + +### Debugging the PHP target + +Because the PHP target is hosted in a separate repository, you will need to clone the [antlr/php-antlr-runtime](https://github.com/antlr/antlr-php-runtime) +repository into the `runtime/PHP` and install the dependencies with `composer install` before you can run the tests. + +``` +git clone -b dev https://github.com/antlr/antlr-php-runtime.git runtime/PHP +cd runtime/PHP +composer install +``` diff --git a/runtime-testsuite/resources/org/antlr/v4/test/runtime/helpers/Test.php.stg b/runtime-testsuite/resources/org/antlr/v4/test/runtime/helpers/Test.php.stg index 2222ce556d..c4c33f2284 100644 --- a/runtime-testsuite/resources/org/antlr/v4/test/runtime/helpers/Test.php.stg +++ b/runtime-testsuite/resources/org/antlr/v4/test/runtime/helpers/Test.php.stg @@ -17,8 +17,10 @@ use Antlr\Antlr4\Runtime\Tree\TerminalNode; $runtime = \getenv('RUNTIME'); +require_once $runtime . '/vendor/autoload.php'; + \spl_autoload_register(function (string $class) use ($runtime) : void { - $file = \str_replace('\\\', \DIRECTORY_SEPARATOR, \str_replace('Antlr\Antlr4\Runtime\\\', $runtime . '\\\src\\\', $class)) . '.php'; + $file = \str_replace('\\\', \DIRECTORY_SEPARATOR, $class) . '.php'; if (\file_exists($file)) { require_once $file;