Questions tagged [php-di]

PHP-DI is a simple to use dependency injection container for PHP. It is practical, powerful, and framework-agnostic.

PHP-DI is a simple to use dependency injection container for PHP. It is practical, powerful, and framework-agnostic.

See more:

101 questions
0
votes
1 answer

Is it a bad practice to set an $app instance on the container in Slim Framerwork?

I'm new to this and still trying to wrap my head around DI while creating a small project using Slim Framework. Is it a bad practice to set an $app on the container like this? $container =…
vrerabek
  • 183
  • 1
  • 14
0
votes
1 answer

Slim with PHP-DI: Cannot find classes from autoloader

I'm trying to switch from the pimple container that comes bundled with Slim, to PHP-DI and I'm having an issue with getting the autowiring to work. As I'm restricted to using PHP 5.6, I'm using Slim 3.9.0 and PHP-DI 5.2.0 along with…
GothicAnatomist
  • 146
  • 4
  • 15
0
votes
1 answer

How would I run a cron using auto-wired classes

I'm currently building out an application that uses Slim v4 and PHP-DI for auto-wiring dependencies. This is fantastic besides the fact that I need to build a CRON that utilizes some classes that are auto-wired. Here's my example: class…
DLzer
  • 159
  • 11
0
votes
0 answers

Class "App\Entities\Test" is not a valid entity or mapped super class. PHP, Doctrine

I catch this error Class "App\Entities\Test" is not a valid entity or mapped super class Path to entities is correct Database's name is too correct. I have checked its about million times. My entity: namespace App\Entities; use Doctrine\ORM\Mapping…
user10268561
0
votes
1 answer

Uncaught Error: Call to undefined method App\App::run() in Slim-4 php and php-di

While working with Slim and PHP-DI, got a warning saying Uncaught Error: Call to undefined method App\App::run() The code is as follows: require __DIR__ . "/../vendor/autoload.php"; $app = new \DI\Bridge\Slim\Bridge; $app->run();
Gursewak Singh
  • 642
  • 1
  • 7
  • 20
0
votes
0 answers

why is not print all session value in php di injection container function

I am using print_r(Auth::user()); in container injection function but this container function not allow here $user=Auth::user(); print_r($user); my main container function code. protected static function _makeContainer() { …
0
votes
1 answer

How to use Symfony HttpFoundation with PHP-DI for MVC

I'm struggling to create a working MVC structure for a project. What I'm using: PHP-DI for DI Container skipperbent/simple-php-router for routing Symfony's HttpFoundation Here is my code. container.php $containerBuilder = new…
C. Ovidiu
  • 1,104
  • 2
  • 18
  • 38
0
votes
1 answer

Why PHP definitions in PHP-DI not working?

I try to inject dependencies in my handler (service) in my project class App { public function __construct() { $this->di(); } public function di() { $containerBuilder = new ContainerBuilder; …
Slip
  • 939
  • 6
  • 17
  • 40
0
votes
1 answer

Overriding injected class from routing group in Slim 4?

I have a Slim4 Application composed of several modules separated in different routing groups, like so: $app->group('/app', function(RouteCollectorProxy $app) { /*blah blah*/ })->add(MyMiddleWare::class); $app->group('/api',…
Jonathan DS
  • 2,050
  • 5
  • 25
  • 48
0
votes
0 answers

Integrate doctrine in slim 4 using php-di

Trying to use doctrine with slim 4 and php-di I don't get it running with autowire. Following my setup: index.php $definitions = [ 'settings' => [ 'doctrine' => [ 'dev_mode' => true, 'cache_dir' =>…
SNO
  • 793
  • 1
  • 10
  • 30
0
votes
0 answers

PHP-DI with lazy injection of mysqli shows warning Property access is not allowed yet

I had a console application. My application had used PHP-DI for auto wiring of application and bootstrapping. My services are using mysqli, so I have created it using PHP Di as lazy and my services are using them through auto wiring. //PHP-DI code …
Kathak Dabhi
  • 399
  • 3
  • 16
0
votes
1 answer

Get Slim with PHP-DI (autowiring) working

I tried to get slim with PHP-DI and Autowiring working, without success. Maybe I have a wrong understanding of autowiring. I setup a new project and created the following Index.php: require __DIR__ . '/../vendor/autoload.php'; use…
SNO
  • 793
  • 1
  • 10
  • 30
0
votes
1 answer

PHP-DI definition is not indexed by an entry name in the definition array

I am getting the fatal error below while posting the email and password for JWT Authentication in Slim3 using Postman. How can I solve this? Fatal error: Uncaught Exception: The PHP-DI definition is not indexed by an entry name in the definition…
0
votes
0 answers

PHP-DI configuration seems wrong

I am learning how dependency injection works using this tutorial, and until this point, everything was working as expected. But after adding Routing, it starts to throw exceptions. I skipped to the next step and even tried to download the source…
Belkin
  • 199
  • 15
0
votes
2 answers

PHP-DI not able to wire interface to implementation w/ slim bridge

I'm coming from the world of .net and DI/IOC containers like autofac, ninject etc. I expect, and php-di's documentation seems to imply the following should work: index.php / front controller $containerBuilder = new…
misterManager
  • 1,174
  • 4
  • 12
  • 33