Remote PSR-11 Container Client

Go back Parent node: PHP Namespaces

IO4FallbackContainerClient.php

Description

Remote PSR-11 Container Client.

Example:

 

1. Container Server:

<?php 
namespace{	
 use ProxyManager\Factory\RemoteObject\Adapter\JsonRpc;
 use ProxyManager\Factory\RemoteObjectFactory;
 use Laminas\Http\Client\Adapter\Exception\RuntimeException;
 use Laminas\Json\Server\Client;
 use Laminas\Json\Json;
use Laminas\Json\Server\Server;
	
	
 $StubRunner = require __DIR__.\DIRECTORY_SEPARATOR.'index.php';	 
 $StubRunner->autoloading();
	
 class IO4FallbackContainer  
{
	protected $container;
	public function __construct(?array $definitions = [], ?array $options = []){
		$class = \Webfan\Webfat\App\ContainerCollection::class;
	    $this->container= new $class(array_merge([], $definitions),
				    array_merge(['onFalseGet'=>\IO4\Container\ContainerCollectionInterface::NULL_ONERROR,], $options)['onFalseGet'],
				    array_merge(['callId'=>\IO4\Container\ContainerCollectionInterface::CALL_ID,],
						$options)['callId']);	
	}
	 
	 
    public function containerGetHas($method='has', $id) 
    {  
		$args = func_get_args();
		array_shift($args);
		if('has'===$method){
			return \call_user_func_array([$this,'container'.ucfirst($method)],$args);
		}elseif('get'===$method){
			return \call_user_func_array([$this,'container'.ucfirst($method)],$args);
		}else{
		  return \call_user_func_array([$this,'container'.ucfirst($method)],$args);	
		}
    }	
    protected function containerGet($id) 
    { 
	
		   switch($id){
			//case 'test id 123 from: ' :
			//	$r = true;
			//break;
			default:
				 return $this->container->get($id);
				break;
		}
		
    }
	 
	protected function containerHas($id)
    { 
		$r = false;
		switch($id){
		//	case 'test id 123 from: ' :
			//	$r = true;
		//	break;
			default:
				 $r = $this->container->has($id);
				break;
		}
		return ['has'=>$r];
    }	 
}
  

(static function () : void {
    $server = new Server();
//$server->setClass('Foo', 'FooServiceInterface');  // my FooServiceInterface implementation
    $server->setClass(new IO4FallbackContainer([
		  'test id 123 from: '=> [function(\Psr\Container\ContainerInterface $container, $previous = null) {
			return ['message'=>' from remote ',
				//'keycount'=>count($this->container->getKnownEntryNames()),
				'keycount'=>0,
				'isContainer'=>isset($container), 
			   ];
		  }, 'factory'], 	
	]), IO4FallbackContainer::class);
    $server->setReturnResponse(false);

    $server->handle();
})();
	
}//ns

2. Container Server Client (from webfats stub Default Container):

<?php

 $StubRunner = require __DIR__.\DIRECTORY_SEPARATOR.'index.php';	 
  $StubRunner->autoloading();
 $StubRunner->autoUpdateStub();
 
(static function ($StubRunner) : void {
	    try {
        var_dump($StubRunner->getAsContainer(null)->get('test id 123 from: ')); // bar remote !
    } catch (\Laminas\Http\Client\Adapter\Exception\RuntimeException $error) {
        echo $error->getMessage();

        exit(2);
    }
	
})($StubRunner);

3. Download the index.php required in the examples above.

 

Uses Transforms...

Source code

Alternative Identifiers

IdentifierDescription
aid:D276000186B200055912E35B68A6799F
(No PIX allowed)
OIDplus Information Object Application Identifier (ISO/IEC 7816) More information
guid:5912e35b-4c62-8000-a6f0-27b67cfbf275OIDplus Information Object Custom UUID (RFC4122bis) More information
mac:D2-1F-68-A6-79-9FOIDplus Information Object MAC address, Unicast (AAI)
mac:D3-1F-68-A6-79-9FOIDplus Information Object MAC address, Multicast (AAI)
oid:1.3.6.1.4.1.37476.30.9.1494410075.1755740575OIDplus Information Object OID
x500dn:/​dc=com/​dc=example/​cn=oidplus/​1.3.6.1.4.1.37476.2.5.2.9.4.1=1494410075/​1.3.6.1.4.1.37476.2.5.2.9.4.2=1755740575OIDplus Information Object X.500 DN

CDN/Files
RDAP
Whois
REST API (Documentation)

Share Static link to this page


Deutsch English (USA)
oidplus:login_webfan | Login using Webfan
oidplus:webfan_goto_frdlweb | Frdlweb
oidplus:webfan_goto_webfan | Webfan
oidplus:resources$Tools/Whois.html | Whois Lookup
oidplus:system | System
pen: | IANA Enterprise Numbers
oid: | Object Identifier (OID)
guid: | Globally Unique Identifier (GUID)
other: | Other objects
php: | PHP Namespaces
     php:IO4FallbackContainerClient.php | -- Remote PSR-11 Container Client
circuit: | Circuit Definition
uri: | URI objects
web+fan: | web+fan:// [#@resources]
mac: | MAC adresses (EUI/ELI/AAI/SAI)
ipv4: | IPv4 Network Blocks
ipv6: | IPv6 Network Blocks
java: | Java Package Names
domain: | Domain Names
aid: | Application Identifier (ISO/IEC 7816)
fourcc: | Four-Character-Code (FourCC)
x500dn: | X.500 Distinguished Name
rdap: | RDAP Services
oidplus:login | Login
oidplus:whois | OID-IP / WHOIS
oidplus:com.viathinksoft.freeoid | Register a free OID
oidplus:search | Search
oidplus:resources | Documents and Resources
oidplus:contact | Contact administrator
com.frdlweb.freeweid | Register a free WEID as OID Arc