symfony-2.1

CORS Api with symfony

你说的曾经没有我的故事 提交于 2020-05-27 01:55:32
问题 I should make cross domain API with Symfony. There is some bundle for that? I have tried FOS Rest Bundle but did not seem have solved my problem. 回答1: I advise you to use NelmioCorsBundle: https://github.com/nelmio/NelmioCorsBundle This bundle allows you to send Cross-Origin Resource Sharing headers with ACL-style per-URL configuration. Is very useful for CORS problem 回答2: I'm not sure that's the right way, but I resolved for me: 1) Create new event subscriber (like ResponseSubscriber ) 2)

CORS Api with symfony

元气小坏坏 提交于 2020-05-27 01:55:27
问题 I should make cross domain API with Symfony. There is some bundle for that? I have tried FOS Rest Bundle but did not seem have solved my problem. 回答1: I advise you to use NelmioCorsBundle: https://github.com/nelmio/NelmioCorsBundle This bundle allows you to send Cross-Origin Resource Sharing headers with ACL-style per-URL configuration. Is very useful for CORS problem 回答2: I'm not sure that's the right way, but I resolved for me: 1) Create new event subscriber (like ResponseSubscriber ) 2)

Manually change or catch the message for invalid CSRF token in Symfony2.1

我怕爱的太早我们不能终老 提交于 2020-03-17 07:36:32
问题 I'm using Symfony2.1 . It has a builtin CSRF protection for the forms. The error message returned when the CSRF token is invalid is: " The CSRF token is invalid. Please try to resubmit the form ". I show it on the top of the form in my Twig template by using the classic call: {{ form_errors(form) }} How can I change the returned message? In alternative, a more advanced possibility is to catch this error type in order to show a lot of options/links in my Twig template. Any idea? 回答1: Did you

Doctrine fixtures not working after updating to Symfony 2.1.8

不羁的心 提交于 2020-01-15 03:34:11
问题 After updating a project from Symfony 2.0.22 to 2.1.8 I get this error when executing doctrine:fixtures:load via Terminal Fatal error: Class 'Doctrine\Common\DataFixtures\Loader' not found in {symfony_install_folder}/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/DataFixtures/ContainerAwareLoader.php on line 27 The fixtures worked on 2.0.22 and I've checked the official documentation to see if I've set everything correctly My composer.json looks like this: { "name": "symfony/framework

Symfony2: How to properly include assets in conjunction with Twig template inheritance?

狂风中的少年 提交于 2020-01-12 07:49:06
问题 I'm currently developing a web application using Symfony 2.1.0. I've read through the Templating chapter of the book and I'm trying to include assets (right now, it's just a single stylesheet) in my web pages. I'm using the Three-level inheritance system that is mentioned in the book, and my application structure currently looks like this: app/Resources/views/ base.html.twig: base template, containing title , stylesheets and body blocks. src/My/PageBundle/Resources/views layout.html.twig:

Redirect after login in Symfony 2

别来无恙 提交于 2020-01-11 20:56:34
问题 In Symfony 2 you can set up a target for the logout so that after logout you will be redirected to /main . However with the login you will be redirected to / . Is there a manner to setup a target for a (successful) login as well? firewalls: dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false login: pattern: ^/m/login$ security: false secured_area: pattern: ^/m form_login: check_path: /m/login_check login_path: /m/login logout: path: /m/logout target: /main anonymous: ~ 回答1: Yes.

Redirect after login in Symfony 2

旧巷老猫 提交于 2020-01-11 20:56:30
问题 In Symfony 2 you can set up a target for the logout so that after logout you will be redirected to /main . However with the login you will be redirected to / . Is there a manner to setup a target for a (successful) login as well? firewalls: dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false login: pattern: ^/m/login$ security: false secured_area: pattern: ^/m form_login: check_path: /m/login_check login_path: /m/login logout: path: /m/logout target: /main anonymous: ~ 回答1: Yes.

How can I add a namespace to Symfony 2.1?

廉价感情. 提交于 2020-01-11 14:04:12
问题 I have a 3rd party lib using namespaces I would like to add to the vendor directory. For certain reasons I can't use composer for this lib. Adding it using the add method of ClassLoader does not work for me ("class not found"). In Detail: I am using Symfony 2.1.7. // app/autoload.php use Doctrine\Common\Annotations\AnnotationRegistry; $loader = require __DIR__.'/../vendor/autoload.php'; $loader->add('Example', realpath(__DIR__.'/../vendor/example/src')); AnnotationRegistry::registerLoader