1. Go to this page and download the library: Download teqneers/ext-direct library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
teqneers / ext-direct example snippets
$namingStrategy = new TQ\ExtDirect\Service\DefaultNamingStrategy();
$serviceRegistry = new TQ\ExtDirect\Service\DefaultServiceRegistry(
new Metadata\MetadataFactory(
new TQ\ExtDirect\Metadata\Driver\AnnotationDriver(
new Doctrine\Common\Annotations\AnnotationReader()
)
),
$namingStrategy
);
$eventDispatcher = new Symfony\Component\EventDispatcher\EventDispatcher();
$router = new TQ\ExtDirect\Router\Router(
new TQ\ExtDirect\Router\ServiceResolver(
$serviceRegistry,
new TQ\ExtDirect\Service\ContainerServiceFactory(
/* a Symfony\Component\DependencyInjection\ContainerInterface */
)
),
$eventDispatcher
);
$endpoint = TQ\ExtDirect\Service\Endpoint(
'default', // endpoint id
new TQ\ExtDirect\Description\ServiceDescriptionFactory(
$serviceRegistry,
'My.api',
$router,
new TQ\ExtDirect\Router\RequestFactory(),
'My.api.REMOTING_API'
)
);
$eventDispatcher->addSubscriber(
new TQ\ExtDirect\Router\EventListener\ArgumentConversionListener(
new TQ\ExtDirect\Router\ArgumentConverter(/* a JMS\Serializer\Serializer */)
)
);
$eventDispatcher->addSubscriber(
new TQ\ExtDirect\Router\EventListener\ArgumentValidationListener(
new TQ\ExtDirect\Router\ArgumentValidator(/* a Symfony\Component\Validator\Validator\ValidatorInterface */)
)
);
$eventDispatcher->addSubscriber(
new TQ\ExtDirect\Router\EventListener\ResultConversionListener(
new TQ\ExtDirect\Router\ResultConverter(/* a JMS\Serializer\Serializer */)
)
);
$eventDispatcher->addSubscriber(
new TQ\ExtDirect\Router\EventListener\StopwatchListener(
/* a Symfony\Component\Stopwatch\Stopwatch */
)
);
use TQ\ExtDirect\Annotation as Direct;
/**
* @Direct\Action()
*/
class Service1
{
// service will be instantiated using the parameter-less constructor if called method is not static
}
/**
* @Direct\Action("app.direct.service2")
*/
class Service2
{
// service will be retrieved from the dependency injection container using id "app.direct.service2" if called method is not static
}
/**
* @Direct\Action("app.direct.service3")
*/
class Service3
{
/**
* @Direct\Method()
*/
public function methodA()
{
// regular method
}
/**
* @Direct\Method(true)
*/
public function methodB()
{
// form handler method
}
}
use Symfony\Component\Validator\Constraints as Assert;
/**
* @Direct\Action("app.direct.service4")
*/
class Service4
{
/**
* @Direct\Method()
* @Direct\Parameter("a", { @Assert\NotNull(), @Assert\Type("int") })
*
* @param int $a
*/
public function methodA($a)
{
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.