symfony4

How to add placeholder on input in Symfony 4 form?

戏子无情 提交于 2020-01-06 06:24:10
问题 In my Symfony 4 form, I am try to get a placeholder for my input. I tried the below but I get an error that it is not allowed. Any ideas how else I can achieve this? ->add('firstname', TextType::class, ['label' => 'Vorname ', 'placeholder' => 'Your name',]) As suggested in the documentation I have also tried the below, here I am not getting an error, just nothing is rendering. ->add('firstname', TextType::class, ['label' => 'Vorname '], ['attr' => ['placeholder' => 'Vorname ']]) 回答1: You need

make entities with multiple databases

谁说我不能喝 提交于 2020-01-06 05:03:06
问题 I have to do large refactoring/enhancements on web apps. We decided to use Symfony4. I want to define 2 (or more) databases: the old one and the new one. (In the future, I think to have more location , person databases common at several web apps) In my researches, I use Multiple Entity Managers, create my databases as mentionned, then create my src/Entity/Main and src/Entity/Customer folders. Then, I want to create my entities , especially new one with php bin/console make:entity but it

routing in symfony 4

一个人想着一个人 提交于 2020-01-05 08:01:29
问题 I want to routing for my app and api like this: app: resource: ../src/Controller type: annotation prefix: / api: resource: ../src/Controller/Api type: annotation prefix: /api Q1 : Where should I write this? in config/routes/annotations.yaml or config/routes.yaml . Q2 : what is different between this two file and which one is used for? 回答1: The file config/routes/annotations.yaml was probably created by a flex when applying annotations recipe. I am not 100% sure, but when you want to delete

(Symfony 4) FOS Js Routing Bundle - The route ----— does not exist.

北城以北 提交于 2020-01-05 04:58:12
问题 It seems like the routing yml file isn't being picked up by the Fos Js Routing bundle. Here's what I have done so far: Setup: $./composer.phar require friendsofsymfony/jsrouting-bundle $bin/console assets:install --symlink public $bin/console fos:js-routing:dump --format=json --target=public/js /fos_js_routes.json In base.html.twig: <script src="{{ asset('bundles/fosjsrouting/js/router.min.js') }}"></script> <script src="{{ path('fos_js_routing_js', { callback: 'fos.Router.setData' }) }}"><

Unable to create Twig Global Variable in Symfony 4

筅森魡賤 提交于 2020-01-05 04:56:14
问题 I have already done it using Symfony 3.3 but with Symfony 4 it's not working. App\Twig\NotifExt: public function getGlobals(){ $count = 'Hello World'; return array('count' => $count); } twig_extensions.yaml: twig: globals: 'count': '%count%' base.html.twig: <a class="nav-item nav-link" href="#">{{ count }} </a> I have done something similar in the previous version and it's working well, but with Symfony 4 I'm getting the following error: You have requested a non-existent parameter "count".

Call to a member function guessExtension() on string

我只是一个虾纸丫 提交于 2020-01-03 18:36:06
问题 In Symfony 4 I'm getting this error: Call to a member function guessExtension() on string In previous I used same code to upload image and doing well, but here i'm getting error. Has anyone faced the same issue and solved? $em = $this->getDoctrine()->getManager(); $imageEn = new Image(); $form = $this->createForm(ImageUploadType::class, $imageEn); $form->handleRequest($request); if($form->isSubmitted() && $form->isValid()){ /** @var Symfony\Component\HttpFoundation\File\UploadedFile $file */

How to pass parameters to a custom Doctrine type in Symfony4

人走茶凉 提交于 2020-01-03 02:21:05
问题 I have developed a new Doctrine type to encrypt strings. <?php namespace App\Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\StringType; use App\Security\Encoder\OpenSslEncoder; class EncryptedStringType extends StringType { const MTYPE = 'encrypted_string'; private $cypherMethod; private $iv; private $privateKey; public function convertToPHPValue($value, AbstractPlatform $platform) { $openSslEncoder = new OpenSslEncoder($this->cypherMethod, $this-

PHPUnit Error: Class not found

孤者浪人 提交于 2020-01-01 19:25:11
问题 I'm using symfony 4.0 and using "symfony/phpunit-bridge": "^4.0" in composer.json. I have installed phpunit-bridge using command composer require --dev phpunit . Now when I run vendor\bin\simple-phpunit tests/Handler It shows this error C:\xampp\htdocs\symfonydemo>vendor\bin\simple-phpunit tests/Handler PHPUnit 6.3.1 by Sebastian Bergmann and contributors. Testing tests/Handler E 1 / 1 (100%) Time: 173 ms, Memory: 4.00MB There was 1 error: 1) App\Tests\Handler\CalculatorResultHandlerTest:

How to access not-injected services directly on Symfony 4+?

最后都变了- 提交于 2019-12-31 07:41:51
问题 I'm trying to update Symfony 2.8 to Symfony 4 and I am having serious problems with the Services Injection. I'm looking the new way to use Services inside Controllers, with auto-wiring: use App\Service\AuxiliarService; class DefaultController extends AbstractController { public function index(AuxiliarService $service) { $var = $service->MyFunction(); .... This way works fine, but I dislike the explicit way to refer MyService as a parameter of the function. This way I don't even need to

How to access not-injected services directly on Symfony 4+?

a 夏天 提交于 2019-12-31 07:41:33
问题 I'm trying to update Symfony 2.8 to Symfony 4 and I am having serious problems with the Services Injection. I'm looking the new way to use Services inside Controllers, with auto-wiring: use App\Service\AuxiliarService; class DefaultController extends AbstractController { public function index(AuxiliarService $service) { $var = $service->MyFunction(); .... This way works fine, but I dislike the explicit way to refer MyService as a parameter of the function. This way I don't even need to