symfony4

Symfony 4 + LDAP

独自空忆成欢 提交于 2019-12-11 07:04:14
问题 I want to set up on an application developed under symfony 4 the authentication system using LDAP component. I already tested directly and I was able in a controller to get user(s) datas using: $ldap = Ldap::create('ext_ldap', array( 'host' => 'my-server', 'encryption' => 'none', )); ... But i need to use a login form with userPrincipalName field and password field. here is the code : #service.yaml parameters: ldap.host: XX.XX.XX.XX services: #... App\Service\LdapConnection: arguments: ['

Symfony 4 API Rest PUT : Map data to database entity

我是研究僧i 提交于 2019-12-11 06:36:28
问题 I'm a begginer in Symfony 4 and I'm developing an API Rest. I want to create a PUT resource that can handle many update cases. In my case, I have a user with many properties but I will take an example with 3 properties to keep things simple : User { username, email, password } My PUT resource can be called in order to update Username, update Email or update Password. For example, to update Username, the user of my API will send a PUT request with only username : { username: "New username" }

Symfony isGranted(“ROLE_ADMIN”) not working properly

久未见 提交于 2019-12-11 06:06:16
问题 I have a security.yaml like this: api_documentary: pattern: ^/api/v1/documentary fos_oauth: true stateless: false methods: [POST, PUT, DELETE] - { path: ^/api/v1/documentary, roles: IS_AUTHENTICATED_ANONYMOUSLY } I want the firewall to be on (accessed by access token) on the following routes ^/api/v1/documentary POST, PUT, DELETE I want the firewall to be off on the routes: GET and GET ALL If I exclude GET from methods: [] above I can access them publicly, however something weird happens: The

Alice fixtures - Persist and reference a first set of entities/objects

空扰寡人 提交于 2019-12-11 06:02:59
问题 Alice has given away the persistence layer in 3.x. In the attempt of migrating from 2.2 to 3.0.x, … I need to load and persist some fixtures first (so their id get populated) and then reference those entities ids from another bunch of fixture files. How can this be achieved ? I guess I may have to loop and load multiple fixture files sets separately but I have no idea how objects references will subsist in such scenario. My setup currently doesn't work but causes the following error to prompt

How to stop perfoming on XHR requests when the user is logout in Symfony?

独自空忆成欢 提交于 2019-12-11 05:58:04
问题 Suppose I have opened my project in 2 different window and I logout using one of the window or you can say session is timed-out/expired (any one of the situation). After that in another window I am able to perform XHR requests when session is destroyed. To over come this I have searched a lot and implemented some of it. I added a event listener but it did not worked. namespace Webkul\CampusConnect\EventListener; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security

Converting any base64 file to a file and moving to the targeted path in php / Symfony 4

孤街醉人 提交于 2019-12-11 05:37:33
问题 thanks in advance I am creating the API in symfony 4 for just uploading the base64 image or any file through POSTMAN and I have to move the file to the targeted directory. I have written the below code in the controller. Through controller I am trying to move the file to the directory, but I am getting the error as : Uncaught Warning: file_put_contents(images/5c78de505abdd.svg): failed to open stream: No such file or directory {"exception":"[object] (ErrorException(code: 0): Warning: file_put

Serialization of 'Symfony\Component\HttpFoundation\File\File' is not allowed, Symfony4

巧了我就是萌 提交于 2019-12-11 05:09:23
问题 I've added an avatar image to my User class. When I wanted to render my edit form, I got this error Serialization of 'Symfony\Component\HttpFoundation\File\File' is not allowed I tried to solve the problem by implementing \Serializable in my User class according to Symfony Official Documentation. But when I implemented that,It redirected to login page and the Authentication turned to anon. and by logging in again, it redirected to login page again and stay anon. too. I should mention that I

Error when making a migration on doctrine

核能气质少年 提交于 2019-12-11 02:56:47
问题 I'm trying to create a table into a sql server by making a migration for the entity I just created, but it throws an exception when executing the query: SQLSTATE [42000, 15135]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Object is invalid. Extended properties are not permitted on 'dbo.[user].roles', or the object does not exist. By using maker-bundle I created a new User entity I made the migration: $ php bin/console make:migration Success! Next: Review the new migration "src

Why does calling encodePassword() with identical salts and passwords produces diffent hashes in Symfony 4?

人盡茶涼 提交于 2019-12-10 22:46:34
问题 In UserPassword encoder, public function encodePassword(UserInterface $user, string $plainPassword) { $encoder = $this->encoderFactory->getEncoder($user); return $encoder->encodePassword($plainPassword, $user->getSalt()); } encoder gets the salt from user entity. I set a static variable to the getSalt() in User entity: public function getSalt() { return 'my-static-salt'; } But when I encode: $password = $encoder->encodePassword($user, "my-password"); $password2 = $encoder->encodePassword(

External service configuration in Symfony 4

若如初见. 提交于 2019-12-10 16:17:00
问题 I'm trying to use imports in services.yaml to move some services definitions to separate file. Here you can find this in symfony doc. But when i'm trying to do this I'm getting an error: Cannot autowire service "App\Domain\Test\Test": argument "$param" of method "__construct()" must have a type-hint or be given a value explicitly. Here are my config files: # services.yaml imports: - { resource: services/test.yaml } services: _defaults: autowire: true autoconfigure: true public: false App\: