1. Go to this page and download the library: Download whitedigital-eu/config-pack library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
whitedigital-eu / config-pack example snippets
use WhiteDigital\Config\Faker;
use WhiteDigital\Config\Traits\FakerTrait;
class Test
{
use FakerTrait;
public function __construct(Faker $faker)
{
self::setFaker($faker);
}
public function test(): string
{
return self::text();
}
}
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Config\ConfigPackConfig;
return static function (ConfigPackConfig $config, ContainerConfigurator $container): void {
if (in_array($container->env(), ['dev', 'test', ], true)) {
$config
->seed(123)
->locale('en_US');
}
};
use WhiteDigital\Config\Test\AbstractTestCase;
use WhiteDigital\Config\Test\Traits;
class CustomerTest extends AbstractTestCase
{
use Traits\DeleteItem;
use Traits\GetCollection;
use Traits\GetItem;
use Traits\GetItemNotFound;
protected static string $iri = '/api/customers';
public function testPostItem(): int
{
return self::post([
'key1' => self::words(),
'key2' => self::text(),
'key3' => self::randomDecimal(),
])->id;
}
#[Depends('testPostItem')]
public function testPatchItem(int $id): int
{
return self::patch($id, [
'key3' => self::randomDigit(),
])->id;
}
}
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Config\ConfigPackConfig;
return static function (ConfigPackConfig $config, ContainerConfigurator $container): void {
if (in_array($container->env(), ['dev', 'test', ], true)) {
$config
->loginEmail('[email protected]')
->loginPassword('test');
}
};
use Doctrine\Persistence\ObjectManager;
use WhiteDigital\Config\DataFixture\AbstractFixture;
class OneFixture extends AbstractFixture
{
public function load(ObjectManager $manager): void
{
$fixture = (new One())
->setKey1(self::words())
->setKey2(self::rnadomDecimal());
$manager->persist($fixture);
$manager->flush();
$this->reference($fixture);
}
}
class TwoFixture extends AbstractFixture
{
public function load(ObjectManager $manager): void
{
for($i = 0; $i < 10; $i++){
$fixture = (new Two())
->setKey1(self::words())
->setKey2($this->getEntity(One::class));
$manager->persist($fixture);
$manager->flush();
$this->reference($fixture, $i);
}
}
public function getDependencies() : array
{
$dependencies = parent::getDependencies();
$dependencies[] = OneFixture::class;
return $dependencies;
}
}