Questions tagged [symfony4]

1

votes
2

answer
428

Views

Symfony 4 Mock service in functional test

I am testing a service which essentially is mostly serializing an object and sending it via a service to an external system. If I create the typical unittest I would mock the response of the serializer and of the service, which contacts the external system. In fact there would be not much left to te...
Calamity Jane
1

votes
1

answer
92

Views

Symfony 4 how to delete entity from OneToMany relationship

I'm having a bit of a problem deleting an entity assigned to another with a OneToMany relationship. I have an entity called Business and it has a property 'units' which is a collection of Unit entities on a OneToMany relationship (business can have many units). When i try to delete a single unit fro...
Glen Elkins
1

votes
1

answer
422

Views

How to fix “https://repo.packagist.org/packages.json does not contain valid Json”?

I've an issue with composer running on a vagrantbox (Centos 7), which started to just suddenly happen. I've already tried manually running the command/solution mentioned on the link below but to no avail. (To clarify, i'm using vagrant not docker, but it was the closest question i found to my situat...
StacOlem
1

votes
1

answer
42

Views

Symfony can't use mailer attachment AND filesystem

I want to send an email with a file attached to it, with swiftMailer, and after that, I want to delete the same file. But when I do it, it doesnt work. My file is not deleted, the mail is not sent, and there is a weird thing. Two emails are created. Here is the controller: public function rentIsPaid...
1

votes
2

answer
20

Views

ManyToMany new value must be an array or an instance of \Traversable, “NULL” given

I have a ManyToMany relation in my Symfony 4.2.6 application and I would like for it to be possible to have this to be null. So my first entity SpecialOffers is as follows : use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM;...
Dennis de Best
1

votes
2

answer
415

Views

Symfony 4 - controllers in two directories

In my application, I use Symfony 4. I want Symfony to search for controllers in two directories: A and B. I found something like this: controllers: resource: '../src/DirectoryA/Controller/' type: annotation , but it only works for one directory. How can I have Symfony to search for controllers i...
mariusz08
1

votes
2

answer
36

Views

Bundle specific exception listener

Lets say I have 3 different bundles. I am adding to event listeners to each bundle. When there is any exception in Bundle1, then Bundle2 and Bundle3 should not listen it. I have tested it adding to each bundle eventlistener but when there is any error in Bundle2 then Bundle1 will listen try to handl...
MRustamzade
0

votes
0

answer
8

Views

How can I access the birthdate from HWI/OAuthBundle when connecting via google OAuth 2?

I have a PHP Symfony 4.2 application with HWI/OAuthBundle properly configured. I created an OAuth 2 key and secret. I configured it in the hwi_oauth section of the symfony files. I use it to login users via a custom UserProvider. In particular I'm concerned in overwriting the method public function...
Xavi Montero
1

votes
0

answer
435

Views

Symfony/Process fails with exception

I'm trying to execute standalone chromedriver for linux with the Symfony/Process component. Here is the folder structure of the project: . ├── bin │   └── chromedriver-linux ├── composer.json ├── index.php └── vendor In index.php this is the code that I'm trying to...
lostbyte
1

votes
0

answer
403

Views

Symfony - Api Platform - How to automatically add the authorized user as a resource owner

I'm building an API using the new Symfony 4 and API Platform, and what I cannot seem to gather from the documentation is how to automatically add the currently authorized user to a resource upon creation. I am using JWT authentication, and /api/ routes are protected from unauthorized users. I want t...
Danielle Suurlant
1

votes
0

answer
346

Views

Symfony EasyAdmin ManyToMany error when adding : Could not determine access type for property “users” in class “App\Entity\Subject”

I'm trying to do a simple ManyToMany relation between two classes with easyAdmin, when I'm trying to add, nothing happened, so in the configuration yml I added the by_reference false, but I have constantly this error: Could not determine access type for property 'users' in class 'App\Entity\Subject...
akali leona
1

votes
0

answer
241

Views

Symfony 4 Bundle Development

I am trying to write a bundle to manage common functions across multiple App development in Symfony 4. I have created a new blank App and new Blank bundles to which I have gradually been adding functionality. To get both annotation routing and twig template paths I have had to add details to of th...
Craig Rayner
1

votes
0

answer
505

Views

symfony4 swiftmailer non-existent class or interface: “Swift_Mailer”

after having installed swiftmailer with composer on symfony4 composer require mailer I've written a small function to test it /** * @Route('/testmail', name='testmail') */ public function mailAction(\Swift_Mailer $mailer) { $message = (new \Swift_Message('Hello Email')) ->setFrom('[email protected]') -...
Sébastien Grognuz
1

votes
1

answer
189

Views

ApiPlatform + JwtAuthenticationBundle

I am trying to configure api platform with JwtAuthenticationBundle, on top of a Symfony 4 app, without FOSUserBundle. I want to be able to use the swagger interface. # config/packages/api_platform.yaml api_platform: swagger: api_keys: - { name: 'Authorization', type: 'header' } mapping: paths: ['%ke...
MatMouth
1

votes
0

answer
1.1k

Views

Symfony 4 demo with adminlte bootstrap thema

I installed Symfony 4 with the demo pack. After that i added the html pages and fixed the paths to the css files etc. But after I ran php bin/console server:run I am able to see the html page but its not loading any css or js files. In the console i see that these are not loading and giving 404 not...
user8928150
1

votes
1

answer
273

Views

Symfony 4 installation with composer error mkdir(): No such file or directory

when i do composer create-project symfony/skeleton project I have this error on Windows : [ErrorException] mkdir(): No such file or directory. php version : 7.1.9 composer version : 1.6.2 Do you have any idea on this error ?
damien bodilis
1

votes
0

answer
299

Views

Symfony 4: Implement links routes with Hateoas-Bundle

I try the install 'willdurand/hateoas-bundle' inside my project with Symfony4 but there is a problem because the 'HATEOAS-BUNDLE' only working with Symfony3 and below. requires symfony/framework-bundle ~2.3 - v3.4.3 In this case I used willdurand/hateoas but I checked and there is not have BazingaHa...
Guido T.
1

votes
1

answer
1.6k

Views

How to connect Symfony 4 with MSSQL

Is there any way to configure and connect to MSSQL database using Symfony 4? I tried to configure Doctrine, but I get the error that I cannot debug. I'd be grateful for any clues. I've put the line below in .env file: DATABASE_URL=sqlsrv://myname:[email protected]/AzureDB?p...
Publius
1

votes
1

answer
490

Views

Symfony 4 get request issue

I'm trying to get a simple raw json-application request in a simple service instantiated in symfony 4 but it seems different from symfony 3. My route deposit_money: path: /auth/money/deposit methods: [POST] controller: App\Controller\MoneyController::deposit defaults: _format: json My controller...
Roberto Rizzi
1

votes
1

answer
38

Views

allow query param with a dot in the value

I have the following route : misc_email_availability: path: /email-availability/{email} defaults: { _controller: App\Controller\Misc\EmailAvailabilityAction } methods: [GET] requirements: email: .+ But when I hit /email-availability/[email protected] for example, symfony returns a 404, because of t...
VaN
1

votes
0

answer
212

Views

Symfony 4 flex change exception structure

I'm using Symfony 4 + Flex and I'm looking for the best way to change the exception structure. In previous version, when I throw an exception, it was like : { 'code': 400, 'message': 'Your message here' } from a function like : throw new HttpException(400, 'Your message here'); Now with Symfony 4 +...
Clément Andraud
1

votes
4

answer
1.9k

Views

Symfony 4.0.0 Services argument wiring error

I am making a ProductBundle based on FOSUserbundle, but I'm having trouble with the autowiring of service arguments to the FormFactory and ProductManager classes. I keep getting the error: Cannot autowire service 'App\Boa\ProductBundle\Form\Factory\FormFactory': argument '$name' of method '__constr...
CharlesV
1

votes
0

answer
69

Views

Symfony4 / Doctrine2 / FOSRestBundle - Inserting / Updating entities

it's my first time here so I hope so don't be to hard on me ;) ! I'm trying to develop an API Rest on Symfony4 with FosRestBundle, Doctrine2 and JMSSerializer. Here's my problem : I have 3 entities organized such as : client which contains extras and a culture culture extra My annotations and associ...
Jérémy S.
1

votes
1

answer
356

Views

Symfony 4 one entity, two entity Manager

Hello everyone, I'm trying to have 2 entityManagers for one entity in Symfony4 but I have some trouble to do this. When I persist an entity it works,(For example if have two entity Mananagers : Customer and Default ,when I use Customer or Default to persist) but when I want to use Repository, The fi...
Mendrika RALISON
1

votes
1

answer
318

Views

Symfony 4: services are shown in the console but not autoinject

[email protected]:/data/projects/graylist$ ./bin/console debug:container | grep client_manager fos_oauth_server.client_manager alias for 'fos_oauth_server.client_manager.default' fos_oauth_server.client_manager.default FOS\OAuthServerBundle\Docu...
Hett
1

votes
3

answer
1.4k

Views

Symfony 4 debug production environments

how to debug Symfony 4 project on production environment? I mean in a way that only I from particular IP can do it. In Symfony 2/3 I have app_dev.php controller. How to do this with Symfony 4 and Apache? If I change in .env or via VirtualHost APP_ENV to dev then all app users will see debug toolbar...
Tom
1

votes
0

answer
26

Views

how to filter a proprety in configureShowFields

I need to get only accepted applications in the list of offers Applications Entity has 'state' as proprety . if the application is accepted 'state' get 'true' protected function configureListFields(ListMapper $listMapper) { $listMapper ->add('id') ->add('job') ->add('mission') ->add('applications')...
Mouna Ben Hmida
1

votes
0

answer
31

Views

Auto-wiring: 2 application libraries (services) wanting to talk to each other

I've come across a problem with the auto-wiring approach to dependency injection for libraries registered as application services, when 2 libraries want bi-directional access to (some of) each others' public functions. It appears that if you try to inject service A into service B and vice versa you...
Adambean
1

votes
1

answer
39

Views

Defining parameters by environment vars that may not exist

How can parameters be defined so that they are set by environment variables, but they won't cause an error when the environment variable doesn't exist. In other words, they are parameters not required, but defined by environment variables when they exist. foo: '%env(resolve:MYFOO)%' The example abov...
Coder1
1

votes
1

answer
529

Views

Symfony 4: How can i pass the current cache instance into a service/controller?

As i understand it right, symfony 4 has its 'own' cache instance. I would like to use it in my controllers and services, but fail to do so. My /config/packages/framework.yaml looks like: framework: secret: '%env(APP_SECRET)%' #default_locale: en #csrf_protection: ~ #http_method_override: true # Ena...
k00ni
1

votes
1

answer
160

Views

Rest API using Symfony4

I have been creating REST API using symfony4, I have installed FosRestBundle and I configured it to return object directly from the controller. I want to return an object from the controller but I get the error Warning: ReflectionObject::__construct() expects parameter 1 to be object, null given Mov...
Naruto Uzumaki
1

votes
0

answer
24

Views

DiscriminatorMap Fatal error: Allowed memory size

When upgrading an application from Symfony 3 to Symfony 4 I ran into a memory issue. I've tracked it down to a used DiscriminatorMap. A little pseudo code: /** * @ORM\InheritanceType('SINGLE_TABLE') * @ORM\DiscriminatorColumn(name='type', type='string') * @ORM\DiscriminatorMap({'person' = '\App\Ent...
Devigner
1

votes
0

answer
93

Views

Symfony tests fail

I wanted to contribute some code to Symfony 4. Therefore I followed the guide (https://symfony.com/doc/current/contributing/code/patches.html), forked Symfony and invoked the tests. The guide says 'PHP 5.5.9 or above', however the tests fail due to PHP 7 new syntax. So I switched to PHP 7.2 running...
fishbone
1

votes
2

answer
422

Views

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

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...
Stphane
1

votes
0

answer
243

Views

Basic Design - Rest communication with Symfony 4 projects

I would like know, how big api frameworks in Symfony 4 would look like. For example, there are three Apis: Price Api (data comes from a different system) Product Api (data comes from a different system) User Api and several symfony client projects (web-catalog, basket, special product configurator...
ABSimon
1

votes
1

answer
1k

Views

Symfony 4 in subdirectory

I'm a French developer and I did install Symfony 4 on a subdirectory of my wamp localhost. My project is named 'cardMaker'. I've a .htaccess file to redirect towards the public directory (index.php) : RewriteEngine On RewriteRule '^$' public/ [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQ...
Sphinx
1

votes
2

answer
591

Views

Symfony 4, One repository class serving multiple entities

New to symfony. I am following this documentation. I have multiple entities mapped from tables imported from another application which did not create repositories automatically and there are a lot of entites to do it by hand. However I want create a single repository class that interfaces multiple e...
Sanjok Gurung
1

votes
2

answer
451

Views

Symfony4: Gos Websocket Error: MySQL server has gone away

I have enabled the PDO Periodic Pings for GOS:WebSocketBundle, I'm still getting this error from time to time: 09:41:28 ERROR [websocket] Connection error occurred Warning: Error while sending QUERY packet. PID=30536 in /home/dev.symfony/libs/composer_vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PD...
Serghei
1

votes
1

answer
519

Views

Symfony4 : Entity objects and controllers - @ParamConverter annotation Error in controller function

this is my first post on Stackoverflow. My question concerns Symfony4 Framework. On my project I would have liked to retrieve some csv file from a controller. However I faced an issue that I have not understood. But let's see what I have done before this. I created my project: composer create-projec...
Emeneror
1

votes
0

answer
149

Views

Symfony4 PHPSpreadSheet gives me twice the results from a foreach loop

i got an issue with the following code : /** * @Route('/dl', name='dl_xls') * @Method({'GET'}) */ public function exportXLS() { $em = $this->getDoctrine()->getManager(); $query = $em->getRepository('App:Post') ->createQueryBuilder('u') ->select('u.title') ->getQuery(); $result = $query->getResult();...
Azurias

View additional questions