2017 © Pedro Peláez
 

library common

Stuff that winds up in every project

image

delboy1978uk/common

Stuff that winds up in every project

  • Tuesday, June 26, 2018
  • by delboy1978uk
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,142 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 55 Versions
  • 9 % Grown

The README.md

common

Build Status Code Coverage Scrutinizer Code Quality
Stuff that winds up in every project., (*1)

Db Credentials

Set the db credentials by passing an array, (*2)

use Del\Common\Config\DbCredentials;

$credentials = new DbCredentials([
    'driver' => 'pdo_mysql',
    'dbname' => 'delboy1978uk',
    'user' => 'dbuser',
    'password' => '[123456]',
]);

DIC Container Factory Service

use Del\Common\ContainerService;

$containerSvc = ContainerService::getInstance();

Service Methods

$containerSvc->setDbCredentials($credentials); // Do this before getContainer() to configure the DBAL Connection
$containerSvc->addEntityPath('path/to/entities'); // You can add multiple paths to get Entities from different packages
$containerSvc->registerToContainer($registrationInterface); // See below

Container Registration Interface

You can create a class in your own packages that will register any definitions that go in the container. Just implement Barnacle\RegistrationInterface. E.g., (*3)

namespace My\Config\Container;


use Barnacle\Container;
use Barnacle\RegistrationInterface;
use Doctrine\ORM\EntityManager;
use My\Repository\Dog as DogRepository;

class DogPackage implements RegistrationInterface
{
    /**
     * @param Container $c
     */
    public function addToContainer(Container $c)
    {
        $c['repository.dog'] = $c->factory(function ($c) {
            /** @var EntityManager $em */
            $em = $c['doctrine.entity_manager'];
            /** @var DogRepository $repo */
            $repo = $em->getRepository('My\Entity\Dog');
            return $repo; 
        });
    }
}

Pimple Container

A Dependency Injection container. Which now contains a configured Doctrine 2 Entity Manager, (*4)

$container = $containerSvc->getContainer();
$em = $container['doctrine.entity_manager'];
$dogRepo = $container['repository.dog'];

Value Objects

There have several value objects which extend Del\Common\Value\AbstractValue., (*5)

use Del\Common\Value\DecimalValue;
use Del\Common\Value\IntValue;
use Del\Common\Value\StringValue;

$money = new DecimalValue(123.45);
$text = new StringValue('Hooray');
$int = new IntValue(500);

echo $money->getValue();
echo $text->getValue();
echo $int->getValue();

The Versions

26/06 2018

dev-master

9999999-dev

Stuff that winds up in every project

  Sources   Download

MIT

The Requires

 

The Development Requires

26/06 2018
26/06 2018
22/06 2018
22/06 2018

dev-dev-master

dev-dev-master

Stuff that winds up in every project

  Sources   Download

MIT

The Requires

 

The Development Requires

07/01 2018
07/01 2018
07/01 2018
19/06 2017
25/05 2017
21/04 2017
02/04 2017
02/04 2017
01/04 2017
01/04 2017
23/03 2017
23/03 2017
22/03 2017
19/11 2016
19/11 2016
19/11 2016
19/11 2016
13/11 2016
07/11 2016
07/11 2016
07/11 2016
07/11 2016
17/10 2016
17/10 2016
05/10 2016
02/10 2016
28/09 2016
28/09 2016
29/08 2016
24/05 2016
24/05 2016
03/04 2016
20/02 2016
04/02 2016
31/01 2016
30/01 2016
25/01 2016
15/01 2016
12/01 2016
12/01 2016
12/01 2016
12/01 2016
12/01 2016
10/01 2016
07/01 2016
06/01 2016
06/01 2016
06/01 2016
05/01 2016

v1.0.1a

1.0.1.0-alpha

Stuff that winds up in every project

  Sources   Download

MIT

The Requires

 

The Development Requires

29/12 2015

v1.0.0

1.0.0.0

Stuff that winds up in every project

  Sources   Download

MIT

The Requires

 

The Development Requires