mirror of
https://github.com/guzzle/guzzle.git
synced 2025-05-01 20:28:41 +02:00
[Build] Moving client template generation to guzzle-client-template repo
This commit is contained in:
parent
64bfbbd466
commit
502af78a33
@ -50,30 +50,4 @@
|
||||
</else>
|
||||
</if>
|
||||
</target>
|
||||
|
||||
<target name="template" description="Create a client project skeleton">
|
||||
<input propertyname="service.path" promptChar=":">Enter the path where you want to install your web service client</input>
|
||||
<input propertyname="service.short_name" promptChar=":">Enter the short name of your client (e.g. guzzle-aws)</input>
|
||||
<input propertyname="service.client_class" promptChar=":">Enter the name of your client class (e.g. UnfuddleClient)</input>
|
||||
<input propertyname="service.namespace" promptChar=":">Enter the root namespace of your client (e.g. Guzzle\Aws)</input>
|
||||
|
||||
<echo msg="Creating web service client project" />
|
||||
|
||||
<fileset id="skeleton" dir="./template">
|
||||
<include name="**/**"/>
|
||||
</fileset>
|
||||
|
||||
<echo msg="Creating folder for project at ${service.path}" />
|
||||
<mkdir dir="${service.path}" />
|
||||
|
||||
<echo msg="Copying files to folder" />
|
||||
<copy todir="${service.path}" overwrite="true">
|
||||
<fileset refid="skeleton" />
|
||||
<filterchain>
|
||||
<expandproperties />
|
||||
</filterchain>
|
||||
</copy>
|
||||
|
||||
<move file="${service.path}/Client.php" toFile="${service.path}/${service.client_class}.php" />
|
||||
</target>
|
||||
</project>
|
2
build/template/.gitignore
vendored
2
build/template/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
coverage
|
||||
phpunit.xml
|
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace ${service.namespace};
|
||||
|
||||
use Guzzle\Common\Inspector;
|
||||
use Guzzle\Http\Message\RequestInterface;
|
||||
use Guzzle\Service\Client;
|
||||
use Guzzle\Service\Description\XmlDescriptionBuilder;
|
||||
|
||||
class ${service.client_class} extends Client
|
||||
{
|
||||
/**
|
||||
* Factory method to create a new ${service.client_class}
|
||||
*
|
||||
* @param array|Collection $config Configuration data. Array keys:
|
||||
* base_url - Base URL of web service
|
||||
*
|
||||
* @return ${service.client_class}
|
||||
*
|
||||
* @TODO update factory method and docblock for parameters
|
||||
*/
|
||||
public static function factory($config)
|
||||
{
|
||||
$default = array();
|
||||
$required = array('base_url');
|
||||
$config = Inspector::prepareConfig($config, $default, $required);
|
||||
|
||||
$client = new self($config->get('base_url'));
|
||||
$client->setConfig($config);
|
||||
|
||||
// Add the XML service description to the client
|
||||
// Uncomment the following two lines to use an XML service description
|
||||
// $builder = new XmlDescriptionBuilder(__DIR__ . DIRECTORY_SEPARATOR . 'client.xml');
|
||||
// $client->setDescription($builder->build());
|
||||
|
||||
return $client;
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once $_SERVER['GUZZLE'] . '/vendor/Symfony/Component/ClassLoader/UniversalClassLoader.php';
|
||||
|
||||
use Symfony\Component\ClassLoader\UniversalClassLoader;
|
||||
|
||||
$loader = new UniversalClassLoader();
|
||||
$loader->registerNamespaces(array(
|
||||
'Guzzle' => $_SERVER['GUZZLE'] . '/src',
|
||||
'Guzzle\\Tests' => $_SERVER['GUZZLE'] . '/tests'
|
||||
));
|
||||
$loader->register();
|
||||
|
||||
spl_autoload_register(function($class) {
|
||||
if (0 === strpos($class, '${service.namespace}\\')) {
|
||||
$path = implode('/', array_slice(explode('\\', $class), 2)) . '.php';
|
||||
require_once __DIR__ . '/../' . $path;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// Register services with the GuzzleTestCase
|
||||
\Guzzle\Tests\GuzzleTestCase::setMockBasePath(__DIR__ . DIRECTORY_SEPARATOR . 'mock');
|
||||
\Guzzle\Tests\GuzzleTestCase::setServiceBuilder(\Guzzle\Service\ServiceBuilder::factory(array(
|
||||
'test.${service.short_name}' => array(
|
||||
'class' => '${service.namespace}\${service.client_class}'
|
||||
)
|
||||
)));
|
@ -1,38 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
-- You must ensure that the values in the php sections are correct before
|
||||
-- attempting to run the tests.
|
||||
-->
|
||||
<phpunit bootstrap="./Tests/bootstrap.php" colors="true">
|
||||
|
||||
<php>
|
||||
<!--
|
||||
-- Change the following value to the path of your Guzzle installation
|
||||
-- e.g. /Users/michael/projects/guzzle
|
||||
-->
|
||||
<server name="GUZZLE" value="/path/to/guzzle" />
|
||||
|
||||
<!--
|
||||
-- Guzzle tries to figure out the path to mock files automatically.
|
||||
-- Set the following value to "1" if your Guzzle service contains
|
||||
-- multiple clients under one service namespace (e.g. Aws\S3, Aws\Sqs)
|
||||
-->
|
||||
<server name="GUZZLE_SERVICE_MULTI" value="0" />
|
||||
</php>
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="guzzle-service">
|
||||
<directory suffix="Test.php">./Tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./</directory>
|
||||
<exclude>
|
||||
<directory>./Tests</directory>
|
||||
<directory>./docs</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
Loading…
x
Reference in New Issue
Block a user