1. Go to this page and download the library: Download cosmologist/gears 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/ */
StringType::sentences('Fry me a Beaver. Fry me a Beaver! Fry me a Beaver? Fry me Beaver no. 4?! Fry me many Beavers... End);
[
[0] => 'Fry me a Beaver.',
[1] => 'Fry me a Beaver!',
[2] => 'Fry me a Beaver?',
[3] => 'Fry me Beaver no. 4?!',
[4] => 'Fry me many Beavers...',
[5] => 'End'
]
StringType::words('Fry me many Beavers... End'); // ['Fry', 'me', 'many', 'Beavers', 'End']
StringType::unword('Remove word from text', 'word'); // 'Remove from text'
// Current locale used
NumberType::spellout(123.45); // one hundred twenty-three point four five
// Specific locale used
NumberType::spellout(123.45, 'ru'); // сто двадцать три целых сорок пять сотых
use Cosmologist\Gears\Symfony\Form\FormUtils;
use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapper;
use Symfony\Component\Validator\Exception\ValidationFailedException;
if ($form->isSubmitted()) {
try {
return $this->handler->create($form->getData());
} catch (ValidationFailedException $exception) {
$violationMapper = new ViolationMapper();
foreach ($exception->getViolations() as $domainViolation) {
$violationMapper->mapViolation(FormUtils::convertDomainViolationToFormViolation($domainViolation), $form);
}
}
}
return $form->createView();
use Cosmologist\Gears\Symfony\Form\DataFormsMapperDefaultTrait;
class TransactionFormType extends AbstractType implements DataMapperInterface
{
use DataFormsMapperDefaultTrait;
#[Override]
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('name', TextType::class)
->setDataMapper($this);
}
#[Override]
public function mapFormsToData(Traversable $forms, mixed &$viewData): void
{
$forms = iterator_to_array($forms);
$viewData = new Contact($forms['name']->getData());
}
use Cosmologist\Gears\Symfony\Validator\ValidationFailedException;
ValidationFailedException::violate($foo, "Foo with invalid bar");
ValidationFailedException::violate($foo, "Foo with invalid {{ bar }}", compact('bar'));
ValidationFailedException::violate($foo, "Foo with invalid bar", propertyPath: 'bar');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.