Questions tagged [pimple]

Pimple is a small Dependency Injection Container for PHP 5.3 that consists of just one file and one class (about 50 lines of code).

Pimple is, according to its website, a small Dependency Injection Container for PHP 5.3 that consists of just one file and one class (about 50 lines of code).

Pimple is created by the same author of the Symfony framework.

46 questions
0
votes
1 answer

Modify admin configuration values on save

I have created a configuration form in Grav's admin panel, and I want to extend/modify some of it's values on save. More precisely, I have a list form element that looks like this in the blueprint: topics: type: list fields: .name: …
Benni
  • 1,023
  • 11
  • 15
0
votes
0 answers

Lazy service injector PHPDoc

I am looking for a solution to declare properly a lazy service injector for the PhpStorm IDE. Here is an example: $app = new Silex\Application(); /** * ??? */ $app['file'] = function() { return new M_file(); };
Samuel C.
  • 55
  • 6
0
votes
1 answer

how to use a dependency container in a php file that isn't a class in Slim 3

I have this dependency container for my database. $container['db'] = function ($container) { $db = $container['settings']['db']; $conn = db2_connect($db['database'], $db['username'], $db['password']); return $conn; }; I can use this in…
moe
  • 725
  • 2
  • 8
  • 19
0
votes
1 answer

Pimple's ServiceProvider not getting options on register

I have had a fair amount of working with Silex and its dependency handling mechanism through Pimple. I am trying to extend the whole dependency injection thing to be able to resolve classes and/or instances through Pimple's container (Dependency…
scruffycoder86
  • 527
  • 1
  • 5
  • 24
0
votes
0 answers

How can I use dependancies in a pimple DIC which need constructor arguments in Slim 3?

This questions is probably best explained with some code snippets. First I create the factory method in the pimple container to create or return the Blah object: $container['blah'] = $container->factory(function ($c) { return new Blah(); }); Then…
John Hunt
  • 4,265
  • 8
  • 45
  • 59
0
votes
1 answer

WebTestCase fails after Silex 2 upgrade

I have the following base lass for controller tests: public function createApplication() { include __DIR__ . '../web/index_dev.php'; $app['debug'] = true; $app['session.test'] = true; $app['helper'] = function ($app) { …
nKognito
  • 6,297
  • 17
  • 77
  • 138
0
votes
1 answer

Bloated Pimple Container - Is this normal?

So I've just integrated Pimple into a project and the situation I'm in now is that I have a file at: /application/config/pimple.php With 400+ of these in it: /* Instantiate new Class */ $this->container['Some_class'] =…
Donal.Lynch.Msc
  • 3,365
  • 12
  • 48
  • 78
0
votes
1 answer

How do you Inject Valitron with Pimple and reuse

So I've been using the Valitron Library to validate posted forms mostly and have run into some issues. The constructor accepts the data to be validated and this causes problems when you inject the library as a dependency with Pimple or some other…
Donal.Lynch.Msc
  • 3,365
  • 12
  • 48
  • 78
0
votes
1 answer

Update used pimple version in Silex application

I'm currently creating an application using silex 1.3. I want to use the dflydev doctrine orm service provider. For this service provider pimple >=2.1 is needed - but my silex version comes with pimple 1.x. I've tried to install a newer version via…
user2345998
  • 649
  • 13
  • 31
0
votes
0 answers

Silex/Pimple: app parameter not updated instantly by middleware

I use the Silex/Pimple container to store parameters for my application. Some of those parameters are set using middleware. Now I have come across the problem where I want to access a parameter value that should have been set through middleware. But…
Jelle V
  • 67
  • 1
  • 6
0
votes
1 answer

Pimple is always returned as an array

I have this trait use Pimple\Container; trait ContainerAwareTrait { protected $container; public function setContainer(Container $container = null) { if (null !== $this->container) { $this->container = $container; …
designermonkey
  • 1,078
  • 2
  • 16
  • 28
0
votes
0 answers

Dependancy Injection with Pimple - Passing closure

i have simple app and i'm trying to start using DI container. I downloaded Pimple, studied the code and documentation. After a while i have come to funny thing. I have two classes, which in special cases communicate between themselves. class Foo { …
M.Svrcek
  • 5,485
  • 4
  • 25
  • 33
0
votes
1 answer

Pimple dependency injection static or object

Pimple help re-use the same object across application, and manage dependecy. but how to manage Pimple itself? Should I create a global object? Or make it static class? Or use a function? I would like to access on Pimple methods from anywhere,…
0
votes
1 answer

Silex, using Twig in service

I'm creating an application in Silex. I want to use Twig to render templates in my service which is loading by Pimple. I need this for mailer class. I started writing application based on silex-skeleton, so I have an twig environment in…
Jakub Zawiślak
  • 5,122
  • 2
  • 16
  • 21
0
votes
1 answer

Pimple - extend object definition

I'm rebuilding my current code and I'm trying to do it with dependency injection. I've downloaded Pimple and in one file, I'm trying to create a few examples for myself. In the documentation I came to method extend, but I'm not able to make it work.…
M.Svrcek
  • 5,485
  • 4
  • 25
  • 33