THRIFT-4474: Use PSR-4 autoloader by default
Client: php
This closes #1479
diff --git a/test/php/Makefile.am b/test/php/Makefile.am
index 28357f6..72f7fc5 100755
--- a/test/php/Makefile.am
+++ b/test/php/Makefile.am
@@ -20,8 +20,8 @@
stubs: ../ThriftTest.thrift
$(THRIFT) --gen php ../ThriftTest.thrift
$(THRIFT) --gen php:inlined ../ThriftTest.thrift
- $(MKDIR_P) gen-php-psr4
- $(THRIFT) -out gen-php-psr4 --gen php:psr4 ../ThriftTest.thrift
+ $(MKDIR_P) gen-php-classmap
+ $(THRIFT) -out gen-php-classmap --gen php ../ThriftTest.thrift
php_ext_dir:
mkdir -p php_ext_dir
@@ -33,7 +33,7 @@
check: stubs php_ext_dir
clean-local:
- $(RM) -r gen-php gen-phpi gen-php-psr4 php_ext_dir
+ $(RM) -r gen-php gen-phpi gen-php-classmap php_ext_dir
client: stubs php_ext_dir
php TestClient.php
diff --git a/test/php/TestPsr4.php b/test/php/TestClassmap.php
similarity index 96%
rename from test/php/TestPsr4.php
rename to test/php/TestClassmap.php
index d30bf1c..6fd1594 100644
--- a/test/php/TestPsr4.php
+++ b/test/php/TestClassmap.php
@@ -18,6 +18,6 @@
*/
<?php
-$GEN_DIR = 'gen-php-psr4';
+$GEN_DIR = 'gen-php-classmap';
include_once('TestClient.php');
?>
diff --git a/test/php/TestClient.php b/test/php/TestClient.php
index aa42e09..acd901d 100755
--- a/test/php/TestClient.php
+++ b/test/php/TestClient.php
@@ -2,7 +2,8 @@
namespace test\php;
-require_once __DIR__.'/../../vendor/autoload.php';
+/** @var \Composer\Autoload\ClassLoader $loader */
+$loader = require __DIR__ . '/../../vendor/autoload.php';
use Thrift\ClassLoader\ThriftClassLoader;
@@ -13,13 +14,14 @@
$MODE = 'normal';
}
-$loader = new ThriftClassLoader();
-if ($GEN_DIR === 'gen-php-psr4') {
- $loader->registerNamespace('ThriftTest', $GEN_DIR);
+
+if ($GEN_DIR == 'gen-php') {
+ $loader->addPsr4('', $GEN_DIR);
} else {
+ $loader = new ThriftClassLoader();
$loader->registerDefinition('ThriftTest', $GEN_DIR);
+ $loader->register();
}
-$loader->register();
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -93,7 +95,7 @@
$MODE = substr($arg, 12);
} else if (substr($arg, 0, 11) == '--protocol=') {
$PROTO = substr($arg, 11);
- }
+ }
}
$hosts = array('localhost');