symfony

How to write custom endpoints with parameters not related to any specific entity

前提是你 提交于 2021-02-03 21:26:21
问题 I'm trying to write custom GET endpoints, which must have one or more custom parameters, but not built on top of specific entity. Something like: /assets/{device_id}/{scene_id}/{maybe_other_param} which I imagine to be just own controller class, in which I do something, calculate values from input, read some data manually and return array of entities. What I only get is an Asset entity, but it requires {device} and {scene} to be properties of this entity... I don't want this to work as

Hash user password without User instance in symfony

好久不见. 提交于 2021-02-02 09:28:08
问题 As it can be read in the official documentation, the current procedure to manually hash a password in the Symfony framework, is the following: use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; public function register(UserPasswordEncoderInterface $encoder) { // whatever *your* User object is $user = new App\Entity\User(); $plainPassword = 'ryanpass'; $encoded = $encoder->encodePassword($user, $plainPassword); $user->setPassword($encoded); } The encodePassword method

symfony/serializer usage with object collection

…衆ロ難τιáo~ 提交于 2021-01-29 20:29:40
问题 Symfony serializer lost collection object while denormalizing. Example: We have some entity with collection in the property (I'm using Doctrine ArrayCollection but it is reproduced for any Collection which implement PHP Iterator interface) Let's serialize and deserialize it with Symfony and JMS serializer and compare results: Origin: ^ App\Entity\Entity^ {#195 -rewardItems: Doctrine\Common\Collections\ArrayCollection^ {#179 -elements: array:2 [ 0 => App\Entity\Item^ {#224 -type: 1 } 1 => App

Symfony - VarDumper component makes the profiler crash

China☆狼群 提交于 2021-01-29 17:21:01
问题 When i use dump() function from the VarDumper Component (anything: variable, strings, ints objects), the profiler crashes. The web page shows properly but the profiler won't show up anymore if i use the dump() function. I have a Javascript error in the console: Uncaught TypeError: Cannot read property 'nodeValue' of null at load.maxTries ((index):305) at (index):305 at XMLHttpRequest.xhr.onreadystatechange ((index):305) And i have no clue of what it is. I am using Symfony 4.4.18. Thanks

Uncaught Error: Class 'App\Kernel' not found

好久不见. 提交于 2021-01-29 16:34:57
问题 I'm currently facing an important issue when i want to run any "php bin/console" command: Symfony\Component\ErrorHandler\Error\ClassNotFoundError^ {#29 #message: """ Attempted to load class "Kernel" from namespace "App".\n Did you forget a "use" statement for "Symfony\Component\HttpKernel\Kernel"? """ #code: 0 #file: "./bin/console" #line: 41 } 2020-06-11T15:43:20+00:00 [critical] Uncaught Error: Class 'App\Kernel' not found While my Kernel.php class is normally defined in src/Kernel.php I am

How to configure different prefixes for different bundles in api-platform

放肆的年华 提交于 2021-01-29 15:49:22
问题 Console command debug:router show absolutely ALL resources, from all installed Bundles (entity marked with @ApiResource()) How to configure different prefixes for different bundles? Or selectively disable resources. App ignored any path in resource : config/routes/api_platform.yaml api_platform: resource: . type: api_platform prefix: /api With default config config/packages/api_platform.yaml api_platform: mapping: paths: ['%kernel.project_dir%/src/Entity'] 回答1: https://github.com/api-platform

Symfony2: The session id is too long or contains illegal characters

点点圈 提交于 2021-01-29 15:31:17
问题 I always get this error when I have some time without updating a project, only occurs in the development environment. Warning: session_start() [function.session-start]: The session id contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' How to avoid? or Why does this happen? i use: Symfony 2.0.9 Linux Mint 12 3.0.0-14-generic x86_64 PHP 5.3.6-13ubuntu3.3 回答1: You might be using Mink or Behat. Please, make sure that they are loaded only for their environment and not dev

Generate Twig Template from Twig Template? (CodeGenerator)

我怕爱的太早我们不能终老 提交于 2021-01-29 14:40:17
问题 I write a code generator in Symfony2 with twig. My problem is: I want to create a twig template with a twig template. For a better understanding here an example: I have a twig file that is a template for a PHP Page - so if i run it it generates me PHP code from that twig template. (ex. a Controller for CRUD ) Now I want to generate the view template - but how can i tell twig to use the commands I need for generation and let the dynamic parts for the template as is? Can I change how the tags

dump_destination in symfony/debug-bundle config

ε祈祈猫儿з 提交于 2021-01-29 12:28:54
问题 In my team we work with SF4 and use .env.dist (and so .env) for developer specific config. When we develop we find symfony/var-dumper very useful, however some devs like to dump in browser and some in console using server:dump command which comes with symfony/debug-bundle. It's very annoying to comment out / uncomment debug.dump_destination key over and over after pulling from remote or worry about conflicts when current remote HEAD happens to have this file also edited. I did my best to

PHP Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\vendor\symfony\process\Pipes\WindowsPipes.php on line 140

不打扰是莪最后的温柔 提交于 2021-01-29 11:10:15
问题 Error when i upload video more than 15MB using ajax and Laravel Its show me this error : PHP Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\vendor\symfony\process\Pipes\WindowsPipes.php on line 140 I use Ffmpeg and Symfony/process the error in symfony windowsPipes.php in laravel So what is problem? 回答1: You can set max_execution_time in your php.ini: max_execution_time=300 Or, in your PHP code: ini_set('max_execution_time', 300); // 5 minutes Setting it to zero