Remote PSR-11 Container Client

Zurückkehren Übergeordnet: PHP-Namensräume

IO4FallbackContainerClient.php

Beschreibung

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 Bezeichner

BezeichnerBeschreibung
aid:D276000186B200055912E35B68A6799F
(Keine PIX erlaubt)
OIDplus Information Object Anwendungsbezeichner (ISO/IEC 7816) Mehr Informationen
guid:5912e35b-4c62-8000-a6f0-27b67cfbf275OIDplus Information Object Individuelle UUID (RFC4122bis) Mehr Informationen
mac:D2-1F-68-A6-79-9FOIDplus Information Objekt Unicast MAC-Adresse (AAI)
mac:D3-1F-68-A6-79-9FOIDplus Information Objekt Multicast MAC-Adresse (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 (Dokumentation)

Teilen Statischer Link zu dieser Seite


Deutsch English (USA)
oidplus:webfan_goto_frdlweb | Frdlweb
oidplus:webfan_goto_webfan | Webfan
oidplus:login_webfan | Mittels Webfan anmelden
oidplus:weid_info | WEID Documentation
oidplus:webfan_goto_webfan_home | Webfan Objects
oidplus:resources$Tools/Whois.html | Whois Lookup
oidplus:system | System
pen: | IANA Enterprise Numbers
oid: | Objekt-Bezeichner (OID)
guid: | Globally Unique Identifier (GUID)
other: | Andere Objekte
php: | PHP-Namensräume
     php:IO4FallbackContainerClient.php | -- Remote PSR-11 Container Client
circuit: | Circuit Definition
uri: | URI objects
web+fan: | web+fan:// [#@resources]
mac: | MAC-Adressen (EUI/ELI/AAI/SAI)
ipv4: | IPv4-Netzwerk-Blöcke
ipv6: | IPv6-Netzwerk-Blöcke
java: | Java Paket-Namen
domain: | Domain-Namen
aid: | Anwendungsbezeichner (ISO/IEC 7816)
fourcc: | Vier-Zeichen-Code (FourCC)
x500dn: | X.500 Distinguished Name
oidplus:login | Anmelden
oidplus:whois | OID-IP / WHOIS
oidplus:com.viathinksoft.freeoid | Kostenlose OID registrieren
oidplus:search | Suche
oidplus:resources | Dokumente und Ressourcen
oidplus:contact | Administrator kontaktieren
com.frdlweb.freeweid | Kostenlose WEID as OID Arc registrieren