symfony-2.8

Symfony2 + SonataAdmin - assets not loading

纵然是瞬间 提交于 2019-12-12 02:58:59
问题 I have Symfony 2.8 installed with Sonata Admin Bundle: "sonata-project/admin-bundle": "2.4.*@dev", "sonata-project/doctrine-orm-admin-bundle": "^2.3" The Sonata admin is successfully installed and accessible at http://xxxxx.com/admin, but It can't load JS and CSS files (I get error 404). The files live in web/bundles folder: drwxr--r-- 2 rabotnici rabotnici 4096 Dec 13 01:44 ./ drwxr-x--- 4 rabotnici nobody 4096 Dec 13 01:13 ../ lrwxrwxrwx 1 rabotnici rabotnici 91 Dec 13 01:44 framework ->

Translator::getMessages returns an empty array

♀尐吖头ヾ 提交于 2019-12-11 20:13:47
问题 I'm trying to use the translator.default service in a Controller , but any message I'm trying to translate by means of the trans method returns the untranslated key. /** * @Route("/testT") */ public function testTAction(Request $req) { $translator = $this->get('translator.default'); $translated = $translator->trans('Hello from the other side'); die(dump($translated)); } In order to be sure my keys were correctly loaded I've done the following checks: php app/console translation:update it -

How do I redirect to my site's homepage after my site times-out?

て烟熏妆下的殇ゞ 提交于 2019-12-11 14:58:19
问题 Without modifying the Symfony code, I want my site to automatically redirect the user to my site's homepage and display a message that the user's session has timed out. Currently, when the time-out occurs the user's browser is automatically redirected to a confusing Symfony error that says: Cannot redirect to an empty URL. 500 Internal Server Error - InvalidArgumentException Stack Trace 1. in vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/RedirectResponse.php at line 76 - public

Symfony2 commandline generation of twig templates under global folder (extended)

試著忘記壹切 提交于 2019-12-11 07:39:24
问题 As related to a previous question i asked, and got an answer to, i'm posting this question to further enhance the usability of the answer, the question was how to automatically generate the twig templates under the global folder app/Resources/views/home/home.html.twig while using php app/console generate:controller command. i got a workable answer to this, which is entering the path to the global app folder like so Templatename (optional) [AppBundle:Post:get.html.twig]: ::../../../../app

Symfony Update 2.8 to 3.4

情到浓时终转凉″ 提交于 2019-12-10 08:00:59
问题 I wanted to upgrade my old Symfony project from 2.8 to 4.0 but I stacked at upgrade from 2.8 to 3.4. I used this tutorial for the upgrade Moving to Symfony 3.4. I got some errors while trying to update through composer Composer Upgrade Errors: # php composer.phar update symfony/symfony --with-dependencies Dependency "symfony/polyfill-apcu" is also a root requirement, but is not explicitly whitelisted. Ignoring. Dependency "twig/twig" is also a root requirement, but is not explicitly

Executing closure on Twig

拟墨画扇 提交于 2019-12-10 05:04:06
问题 I'm trying to execute a closure that resides inside an array on a Twig template. Below you could find a simplified snippet of which I'm trying: //Symfony controller ... $funcs = array( "conditional" => function($obj){ return $obj->getFoo() === $obj::TRUE_FOO } ); $this->render('template_name', array('funcs' => $funcs)); {# Twig template #} {# obj var is set #} ... {% if funcs.conditional(obj)%} <p>Got it</p> {% endif %} When Twig renders the template, throws an exception complaining about an

symfony: How to set configuration parameters files for different environments?

百般思念 提交于 2019-12-08 20:16:22
问题 How to setup a different configuration parameters file for each environment? At the moment parameters in parameters.yml are used in both dev and prod environment, but I need different parameters in order to deploy my app in prod. 回答1: You can put all the parameters used in your dev environment in a app\config\parameters_dev.yml file ( you need to create it ) and then import it in your app\config\config_dev.yml : imports: - { resource: config.yml } - { resource: parameters_dev.yml } So when

SonataProductBundle (symfony 2.8) instead of showing product create form there is “No object types available” button appearing

倾然丶 夕夏残阳落幕 提交于 2019-12-08 06:15:35
问题 There are Sonata Admin with enabled SonataProductBundle. Product entity configured accordingly to documentation. But, upon attempting to create new "Product" in admin panel, "No object types available" button appears instead of edit form of. Here are the configurations: config.yml imports: - { resource: parameters.yml } - { resource: security.yml } - { resource: services.yml } - { resource: sonata/sonata_product.yml } - { resource: '@ApplicationSonataProductBundle/Resources/config/product.yml

Symfony2 - Redirect from non-www to www

只愿长相守 提交于 2019-12-08 04:10:55
问题 I need to redirect my symfony website from "abc.com" to "www.abc.com". I have tried some solutions in stack overflow but they add multiple "www." to the address and others didn't work. Here is my htaccess source. DirectoryIndex app.php <IfModule mod_negotiation.c> Options -MultiViews </IfModule> <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ RewriteRule ^(.*) - [E=BASE:%1] RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%

How to create “two” (chat and admin) or more secured areas with FOSUserBundle

非 Y 不嫁゛ 提交于 2019-12-06 04:06:47
I'm working in a Symfony 2.8.x app and I need to setup two secured areas: chat and admin . This means that chat and admin will use the same login template (if this is possible and I don't need to setup different one for this purpose). I have googled before ask here and there is a few things related showing up and I read a lot of post about this topic: 1 , 2 , 3 , 4 just as an example of them but I am doing something wrong since I can't get this working properly. This is how /app/config/security.yml looks like (just the firewalls and access_control piece of code): security: .... firewalls: