symfony4

Symfony 4 : JS and CSS compiled with Webpack return 404

∥☆過路亽.° 提交于 2019-12-12 10:11:51
问题 I'm building a project with Symfony4 and VueJs, hosted by nginx server and run with Docker. My templates are OK but css and js files are in 404. Here's my nginx configuration : server { listen 80; listen [::]:80; server_name symfony.local; root /var/www/myproject/public; location / { try_files $uri /index.php$is_args$args; } location ~ ^/(index)\.php(/|$) { fastcgi_pass php:9000; fastcgi_split_path_info ^(.+\.php)(/.*)$; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root

Symfony 4: how to load DataFixtures in a KernelTestCase

℡╲_俬逩灬. 提交于 2019-12-12 00:48:00
问题 I got DataFixtures set up, that I can load via console into my test database. $ php bin/console doctrine:fixtures:load --env=test -n > purging database > loading App\DataFixtures\PropertyFixtures > loading App\DataFixtures\UserFixtures > loading App\DataFixtures\UserPropertyFixtures works like a chram But I am lost how to load these fixtures automatically with my service unit tests, without having to run the command manually before testing. There has to be another way! What I found so far is

Sonata Admin List Field Template is Ignored

ⅰ亾dé卋堺 提交于 2019-12-11 20:55:24
问题 I'm using Symfony 4.1.1 and Sonata Admin Bundle 3.35.2. I want to use a custom template for a field in an admin's list view. The template is ignored. I am using Twig as my templating engine. In the admin: # /src/Admin/ImageAdmin.php protected function configureListFields(ListMapper $listMapper) { $listMapper ->add('filename', 'string', ['template' => 'list_image.html.twig']) ; } The template: # /templates/list_image.html.twig {% extends 'SonataAdminBundle:CRUD:base_list_field.html.twig' %} {%

Dependency injection for a bundle controller

末鹿安然 提交于 2019-12-11 19:53:13
问题 I have a simple, working SecurityController that I would like to turn into a bundle so that I can share basic authentication functionality across a few basic websites I create. Everything is working as desired until I try to turn my code into a bundle. I have created my bundle class, a Resources/config/routing.xml file to declare my login and logout routes, have a template in Resources/views/Security/login.html.twig but the following class is throwing an error. <!-- Controller

Codeception how to grab entities by values in array

我只是一个虾纸丫 提交于 2019-12-11 19:16:14
问题 I need to grab many entities by values in array. Method bellow: $arrayOfIds = [1,2,3,4,5]; $I->grabEntitiesFromRepository(Product::class, ['id' => $arrayOfIds]); Return: [Doctrine\DBAL\Exception\SyntaxErrorException] An exception occurred while executing 'SELECT p0_.id AS id_2, p0_.created_at AS created_at_3, p0_.updated_at AS updated_at_4 FROM product p0_ WHERE p0_.id = ?, ?, ?, ?, ?' with params [1, 2, 3, 4, 5]: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in

How to run Mercure in production

早过忘川 提交于 2019-12-11 18:25:55
问题 I'm trying to run Mercure on Symfony within a production env. [1st problem] It seems that I need to keep my ssh connection active in order to keep mercure running. Also, I would like to be able to run multiple instance of Mercure (one per vhost) [2nd problem] As my vhost is already using HTTPS, I'm using the following command to run Mercure: JWT_KEY='4e2da03eda9acdfdb9253ab0f8f9e4011706fd6ba6d8293d9727e833752fb15b' CERT_FILE='/etc/letsencrypt/live/my-project.my-domain.com/fullchain.pem' KEY

symfony 4 twig override default variable

好久不见. 提交于 2019-12-11 18:05:54
问题 I have set a default variable in my view (Twig template). But when I try to override it inside controller it is not happening. This is my view, <div class="content-wrapper"> {% if has_header|default(true) == true %} <!-- Header code --> {% endif %} </div> This is my controller, return $this->render('index.html.twig', [ 'has_header' => false ]); But unfortunately even I added the has added 'has_header' to false it still runs header code. It would be great if someone can help. 回答1: The problem

Lexik JWT Authentification with Sf4 : Uncaught Exception: Unable to find the controller for path “/login_check”

丶灬走出姿态 提交于 2019-12-11 17:42:52
问题 I followed the Sf4 sandbox to install JWT Auth, but still I have this response : 2019-01-03T18:39:27+01:00 [info] Matched route "login_check". 2019-01-03T18:39:27+01:00 [info] Populated the TokenStorage with an anonymous Token. 2019-01-03T18:39:27+01:00 [warning] Unable to look for the controller as the "_controller" parameter is missing. 2019-01-03T18:39:27+01:00 [critical] Uncaught Exception: Unable to find the controller for path "/login_check". The route is wrongly configured. [Thu Jan 3

Symfony The annotation does not exist, or could not be auto-loaded - Symfony Validation with Doctrine

回眸只為那壹抹淺笑 提交于 2019-12-11 17:31:09
问题 We have a legacy app which is not based on symfony. Doctrine is in use and now we would like to add validation to the models. Seems that the Annotations never get autoloaded, even when "use" statements are in use. [Semantical Error] The annotation "@Symfony\Component\Validator\Constraints\NotBlank" in property Test\Stackoverflow\User::$Username does not exist, or could not be auto-loaded. Wrote a small demo application to showcase the problem and how we create the entity manager and

Webpack - Materialize with Symfony

此生再无相见时 提交于 2019-12-11 17:24:18
问题 I'm running a project on Symfony. I want to use for the first Time, Symfony 4, Webpack and Vagrant/Homestead. My host is a Windows 10 My project is host on a VM made with vagrant/Homestead on Debian Wabpack (yarn) is installed So, I've made an "assets" folder inside I have a "css" folder, a "js" folder and a "scss" folder. I've run the command yarn add materialize-css And then I run yarn encore dev --watch (ofc I've run yarn install previously) But when I run my Symfony Website... Materialize