Category : symfony5

With Symfony 5.1 and PHP 7.4, I want to add preload.php in opcache. Symfony documentation : During container compilation (e.g. when running the cache:clear command), Symfony generates a file called preload.php in the config/ directory with the list of classes to preload. opcache.preload=/path/to/project/config/preload.php But when I execute cache:clear, I don’t have preload.php file in /config/ ..

Read more

Symfony: change database dynamically I have similar situation – I need to perform a quick lookup and set the host or database on the fly, based on URI patterns. I have tried getting this to work – but I am not understanding something: <?php namespace AppDecorator; use DoctrineDBALConnection; class DynamicConnection extends Connection { public function ..

Read more

I am attempting to upload a file via an API endpoint controller I have created: /** * @Route("/upload", methods="POST") */ public function upload(Request $request) { $form = $this->createForm(UserFileType::class); $form->handleRequest($request); if (!$form->isSubmitted()) { dd($request->files->get(‘file’)); } … The dd($request->files->get(‘file’)) is showing my file as expected so I am unclear why isSubmitted() is returning false when the method ..

Read more

I have a simple contact form. Within the form I would like to change the color of the help text In FormType I added i. e. the name field: $builder ->add(‘name’, TextType::class, [‘help’ => ‘Pflichtfeld’]) In Twig I have this: <div class="row"> <div class="col"> {{ form_label(ContactForm.name)}} {{ form_widget(ContactForm.name) }} {{ form_help(ContactForm.name, {‘help_attr’: {‘class’:’text-danger’}}) }} </div> ..

Read more

When building a form in symfony form builder changing the choice attribute can be done. However, for the label attribute this doesn’t seem possible. Here is how i modify the choice: $builder->add(‘type’, EntityType::class, [ ‘class’ => Resourcetype::class, ‘multiple’ => true, ‘expanded’ => true, ‘choice_attr’ => function (?Resourcetype $type) { return [‘class’ => $type->getSafeName() . ‘-parent ..

Read more