BC
Size: a a a
BC
AY
mБ
mБ
mБ
AY
G
G
interface IService {
}
interface IFactory {
}
class Service implements IService
{
public function __construct(string $args)
{
}
}
class Factory implements IFactory
{
protected IService $service;
public function __construct(IService $service)
{
$this->service = $service;
}
}
$container->bind(IFactory::class, Factory::class);
$service = $container->make(IFactory::class, ['args' => 'configure']);
V
VY
interface IService {
}
interface IFactory {
}
class Service implements IService
{
public function __construct(string $args)
{
}
}
class Factory implements IFactory
{
protected IService $service;
public function __construct(IService $service)
{
$this->service = $service;
}
}
$container->bind(IFactory::class, Factory::class);
$service = $container->make(IFactory::class, ['args' => 'configure']);
VY
interface IService {
}
interface IFactory {
}
class Service implements IService
{
public function __construct(string $args)
{
}
}
class Factory implements IFactory
{
protected IService $service;
public function __construct(IService $service)
{
$this->service = $service;
}
}
$container->bind(IFactory::class, Factory::class);
$service = $container->make(IFactory::class, ['args' => 'configure']);
G
"autoload": {
"psr-4": {
"App\\": "src/Classes",
"Controllers\\": "src/Controllers",
"Models\\": "src/Models",
"Contracts\\": "src/Contracts"
}
},
G
V
V
ServiceFactory
G
G
ServiceFactory
<?php
namespace App;
use Contracts\{ServiceInterface, ServiceFactoryInterface};
class ServiceFactory implements ServiceFactoryInterface
{
protected $servicee;
public function __construct(ServiceInterface $service)
{
$this->service = $service;
}
public function get(): ServiceInterface
{
return $this->service;
}
}
V
V
вываливается эксепшен fatаl error: uncaught erro: интерфейс not found фабрика служб, а куда шлет по коду то class ServiceFactory implements ServiceFactoryInterface на эту линию
G
вываливается эксепшен fatаl error: uncaught erro: интерфейс not found фабрика служб, а куда шлет по коду то class ServiceFactory implements ServiceFactoryInterface на эту линию
PHP Fatal error: Uncaught Error: Interface 'Contracts\ServiceFactoryInterface' not found in /var/www/html/container/src/Classes/ServiceFactory.php:7
Stack trace:
#0 /var/www/html/container/vendor/composer/ClassLoader.php(444): include()
#1 /var/www/html/container/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile()
#2 [internal function]: Composer\Autoload\ClassLoader->loadClass()
#3 [internal function]: spl_autoload_call()
#4 /var/www/html/container/vendor/illuminate/container/Container.php(830): ReflectionClass->__construct()
#5 /var/www/html/container/vendor/illuminate/container/Container.php(712): Illuminate\Container\Container->build()
#6 /var/www/html/container/vendor/illuminate/container/Container.php(283): Illuminate\Container\Container->resolve()
#7 /var/www/html/container/vendor/illuminate/container/Container.php(826): Illuminate\Container\Container->Illuminate\Container\{closure}()
#8 /var/www/html/container/vendor/illuminate/container/Container.php(712): Illuminate\Container\Container->build()
#9 in /var/www/html/container/src/Classes/ServiceFactory.php on line 7