Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all 3925 articles
Browse latest View live

Empty project symfony + mongo: Attempted to load interface CommandSubscriber in index page

$
0
0

I have a problem with the Symfony 4 project from MongoDB

Empty project Symfony + mongo = Attempted to load interface CommandSubscriber in index page Symfony after installation

error:

Attempted to load interface "CommandSubscriber" from namespace "MongoDB\Driver\Monitoring". Did you forget a "use" statement for another namespace?

doctrine/mongodb-odm                2.0.5  
doctrine/mongodb-odm-bundle         4.1.0  
mongodb/mongodb                     1.5.2

php-mongodb                      1.6.1-1+0~20191219.12+debian10~1.gbpe14612  

mongo 3.6.17

how to fix it?


Installation failed while installing Laravel's Valet due to conflicts

$
0
0

I was having some problems with Laravel's Valet, so I attempted to uninstall and reinstall. Upon reinstallation, when I type the command composer global require laravel/valet I get this extremely lengthy error

Your requirements could not be resolved to an installable set of packages.

Problem 1
- Conclusion: don't install symfony/process v3.4.1
- Conclusion: don't install laravel/valet v2.0.6
- Conclusion: don't install laravel/valet v2.0.5
- Conclusion: don't install laravel/valet v2.0.4
- Conclusion: don't install laravel/valet v2.0.3
- Conclusion: don't install laravel/valet v2.0.1
- Conclusion: don't install symfony/process v3.4.0
- Conclusion: remove symfony/console v4.0.1
- Conclusion: don't install symfony/console v4.0.1
- symfony/process v2.7.0 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.1 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.10 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.11 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.12 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.13 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.14 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.15 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.16 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.17 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.18 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.19 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.2 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.20 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.21 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.22 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.23 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.24 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.25 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.26 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.27 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.28 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.29 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.3 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.30 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.31 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.32 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.33 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.34 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.35 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.36 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.37 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.38 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.39 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.4 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.5 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.6 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.7 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.8 conflicts with symfony/console[v4.0.1].
- symfony/process v2.7.9 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.0 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.1 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.10 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.11 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.12 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.13 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.14 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.15 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.16 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.17 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.18 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.19 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.2 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.20 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.21 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.22 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.23 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.24 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.25 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.26 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.27 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.28 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.29 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.3 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.30 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.31 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.32 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.4 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.5 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.6 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.7 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.8 conflicts with symfony/console[v4.0.1].
- symfony/process v2.8.9 conflicts with symfony/console[v4.0.1].
- symfony/process v3.0.0 conflicts with symfony/console[v4.0.1].
- symfony/process v3.0.1 conflicts with symfony/console[v4.0.1].
- symfony/process v3.0.2 conflicts with symfony/console[v4.0.1].
- symfony/process v3.0.3 conflicts with symfony/console[v4.0.1].
- symfony/process v3.0.4 conflicts with symfony/console[v4.0.1].
- symfony/process v3.0.5 conflicts with symfony/console[v4.0.1].
- symfony/process v3.0.6 conflicts with symfony/console[v4.0.1].
- symfony/process v3.0.7 conflicts with symfony/console[v4.0.1].
- symfony/process v3.0.8 conflicts with symfony/console[v4.0.1].
- symfony/process v3.0.9 conflicts with symfony/console[v4.0.1].
- symfony/process v3.1.0 conflicts with symfony/console[v4.0.1].
- symfony/process v3.1.1 conflicts with symfony/console[v4.0.1].
- symfony/process v3.1.10 conflicts with symfony/console[v4.0.1].
- symfony/process v3.1.2 conflicts with symfony/console[v4.0.1].
- symfony/process v3.1.3 conflicts with symfony/console[v4.0.1].
- symfony/process v3.1.4 conflicts with symfony/console[v4.0.1].
- symfony/process v3.1.5 conflicts with symfony/console[v4.0.1].
- symfony/process v3.1.6 conflicts with symfony/console[v4.0.1].
- symfony/process v3.1.7 conflicts with symfony/console[v4.0.1].
- symfony/process v3.1.8 conflicts with symfony/console[v4.0.1].
- symfony/process v3.1.9 conflicts with symfony/console[v4.0.1].
- symfony/process v3.2.0 conflicts with symfony/console[v4.0.1].
- symfony/process v3.2.1 conflicts with symfony/console[v4.0.1].
- symfony/process v3.2.10 conflicts with symfony/console[v4.0.1].
- symfony/process v3.2.11 conflicts with symfony/console[v4.0.1].
- symfony/process v3.2.12 conflicts with symfony/console[v4.0.1].
- symfony/process v3.2.13 conflicts with symfony/console[v4.0.1].
- symfony/process v3.2.14 conflicts with symfony/console[v4.0.1].
- symfony/process v3.2.2 conflicts with symfony/console[v4.0.1].
- symfony/process v3.2.3 conflicts with symfony/console[v4.0.1].
- symfony/process v3.2.4 conflicts with symfony/console[v4.0.1].
- symfony/process v3.2.5 conflicts with symfony/console[v4.0.1].
- symfony/process v3.2.6 conflicts with symfony/console[v4.0.1].
- symfony/process v3.2.7 conflicts with symfony/console[v4.0.1].
- symfony/process v3.2.8 conflicts with symfony/console[v4.0.1].
- symfony/process v3.2.9 conflicts with symfony/console[v4.0.1].
- Conclusion: remove symfony/process v4.0.1|install symfony/process v2.7.0|install symfony/process v2.7.1|install symfony/process v2.7.10|install symfony/process v2.7.11|install symfony/process v2.7.12|install symfony/process v2.7.13|install symfony/process v2.7.14|install symfony/process v2.7.15|install symfony/process v2.7.16|install symfony/process v2.7.17|install symfony/process v2.7.18|install symfony/process v2.7.19|install symfony/process v2.7.2|install symfony/process v2.7.20|install symfony/process v2.7.21|install symfony/process v2.7.22|install symfony/process v2.7.23|install symfony/process v2.7.24|install symfony/process v2.7.25|install symfony/process v2.7.26|install symfony/process v2.7.27|install symfony/process v2.7.28|install symfony/process v2.7.29|install symfony/process v2.7.3|install symfony/process v2.7.30|install symfony/process v2.7.31|install symfony/process v2.7.32|install symfony/process v2.7.33|install symfony/process v2.7.34|install symfony/process v2.7.35|install symfony/process v2.7.36|install symfony/process v2.7.37|install symfony/process v2.7.38|install symfony/process v2.7.39|install symfony/process v2.7.4|install symfony/process v2.7.5|install symfony/process v2.7.6|install symfony/process v2.7.7|install symfony/process v2.7.8|install symfony/process v2.7.9|install symfony/process v2.8.0|install symfony/process v2.8.1|install symfony/process v2.8.10|install symfony/process v2.8.11|install symfony/process v2.8.12|install symfony/process v2.8.13|install symfony/process v2.8.14|install symfony/process v2.8.15|install symfony/process v2.8.16|install symfony/process v2.8.17|install symfony/process v2.8.18|install symfony/process v2.8.19|install symfony/process v2.8.2|install symfony/process v2.8.20|install symfony/process v2.8.21|install symfony/process v2.8.22|install symfony/process v2.8.23|install symfony/process v2.8.24|install symfony/process v2.8.25|install symfony/process v2.8.26|install symfony/process v2.8.27|install symfony/process v2.8.28|install symfony/process v2.8.29|install symfony/process v2.8.3|install symfony/process v2.8.30|install symfony/process v2.8.31|install symfony/process v2.8.32|install symfony/process v2.8.4|install symfony/process v2.8.5|install symfony/process v2.8.6|install symfony/process v2.8.7|install symfony/process v2.8.8|install symfony/process v2.8.9|install symfony/process v3.0.0|install symfony/process v3.0.1|install symfony/process v3.0.2|install symfony/process v3.0.3|install symfony/process v3.0.4|install symfony/process v3.0.5|install symfony/process v3.0.6|install symfony/process v3.0.7|install symfony/process v3.0.8|install symfony/process v3.0.9|install symfony/process v3.1.0|install symfony/process v3.1.1|install symfony/process v3.1.10|install symfony/process v3.1.2|install symfony/process v3.1.3|install symfony/process v3.1.4|install symfony/process v3.1.5|install symfony/process v3.1.6|install symfony/process v3.1.7|install symfony/process v3.1.8|install symfony/process v3.1.9|install symfony/process v3.2.0|install symfony/process v3.2.1|install symfony/process v3.2.10|install symfony/process v3.2.11|install symfony/process v3.2.12|install symfony/process v3.2.13|install symfony/process v3.2.14|install symfony/process v3.2.2|install symfony/process v3.2.3|install symfony/process v3.2.4|install symfony/process v3.2.5|install symfony/process v3.2.6|install symfony/process v3.2.7|install symfony/process v3.2.8|install symfony/process v3.2.9
- Conclusion: don't install symfony/process v3.3.14|keep symfony/process v4.0.1
- Installation request for symfony/console (locked at v4.0.1, required as ^4.0) -> satisfiable by symfony/console[v4.0.1].
- Installation request for laravel/valet ^2.0 -> satisfiable by laravel/valet[v2.0.0, v2.0.1, v2.0.3, v2.0.4, v2.0.5, v2.0.6].
- Conclusion: don't install symfony/process v4.0.1|install symfony/process v2.7.0|install symfony/process v2.7.1|install symfony/process v2.7.10|install symfony/process v2.7.11|install symfony/process v2.7.12|install symfony/process v2.7.13|install symfony/process v2.7.14|install symfony/process v2.7.15|install symfony/process v2.7.16|install symfony/process v2.7.17|install symfony/process v2.7.18|install symfony/process v2.7.19|install symfony/process v2.7.2|install symfony/process v2.7.20|install symfony/process v2.7.21|install symfony/process v2.7.22|install symfony/process v2.7.23|install symfony/process v2.7.24|install symfony/process v2.7.25|install symfony/process v2.7.26|install symfony/process v2.7.27|install symfony/process v2.7.28|install symfony/process v2.7.29|install symfony/process v2.7.3|install symfony/process v2.7.30|install symfony/process v2.7.31|install symfony/process v2.7.32|install symfony/process v2.7.33|install symfony/process v2.7.34|install symfony/process v2.7.35|install symfony/process v2.7.36|install symfony/process v2.7.37|install symfony/process v2.7.38|install symfony/process v2.7.39|install symfony/process v2.7.4|install symfony/process v2.7.5|install symfony/process v2.7.6|install symfony/process v2.7.7|install symfony/process v2.7.8|install symfony/process v2.7.9|install symfony/process v2.8.0|install symfony/process v2.8.1|install symfony/process v2.8.10|install symfony/process v2.8.11|install symfony/process v2.8.12|install symfony/process v2.8.13|install symfony/process v2.8.14|install symfony/process v2.8.15|install symfony/process v2.8.16|install symfony/process v2.8.17|install symfony/process v2.8.18|install symfony/process v2.8.19|install symfony/process v2.8.2|install symfony/process v2.8.20|install symfony/process v2.8.21|install symfony/process v2.8.22|install symfony/process v2.8.23|install symfony/process v2.8.24|install symfony/process v2.8.25|install symfony/process v2.8.26|install symfony/process v2.8.27|install symfony/process v2.8.28|install symfony/process v2.8.29|install symfony/process v2.8.3|install symfony/process v2.8.30|install symfony/process v2.8.31|install symfony/process v2.8.32|install symfony/process v2.8.4|install symfony/process v2.8.5|install symfony/process v2.8.6|install symfony/process v2.8.7|install symfony/process v2.8.8|install symfony/process v2.8.9|install symfony/process v3.0.0|install symfony/process v3.0.1|install symfony/process v3.0.2|install symfony/process v3.0.3|install symfony/process v3.0.4|install symfony/process v3.0.5|install symfony/process v3.0.6|install symfony/process v3.0.7|install symfony/process v3.0.8|install symfony/process v3.0.9|install symfony/process v3.1.0|install symfony/process v3.1.1|install symfony/process v3.1.10|install symfony/process v3.1.2|install symfony/process v3.1.3|install symfony/process v3.1.4|install symfony/process v3.1.5|install symfony/process v3.1.6|install symfony/process v3.1.7|install symfony/process v3.1.8|install symfony/process v3.1.9|install symfony/process v3.2.0|install symfony/process v3.2.1|install symfony/process v3.2.10|install symfony/process v3.2.11|install symfony/process v3.2.12|install symfony/process v3.2.13|install symfony/process v3.2.14|install symfony/process v3.2.2|install symfony/process v3.2.3|install symfony/process v3.2.4|install symfony/process v3.2.5|install symfony/process v3.2.6|install symfony/process v3.2.7|install symfony/process v3.2.8|install symfony/process v3.2.9|install symfony/process v3.3.14
- laravel/valet v2.0.0 requires symfony/process ~2.7|~3.0 -> satisfiable by symfony/process[v2.7.0, v2.7.1, v2.7.10, v2.7.11, v2.7.12, v2.7.13, v2.7.14, v2.7.15, v2.7.16, v2.7.17, v2.7.18, v2.7.19, v2.7.2, v2.7.20, v2.7.21, v2.7.22, v2.7.23, v2.7.24, v2.7.25, v2.7.26, v2.7.27, v2.7.28, v2.7.29, v2.7.3, v2.7.30, v2.7.31, v2.7.32, v2.7.33, v2.7.34, v2.7.35, v2.7.36, v2.7.37, v2.7.38, v2.7.39, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.10, v2.8.11, v2.8.12, v2.8.13, v2.8.14, v2.8.15, v2.8.16, v2.8.17, v2.8.18, v2.8.19, v2.8.2, v2.8.20, v2.8.21, v2.8.22, v2.8.23, v2.8.24, v2.8.25, v2.8.26, v2.8.27, v2.8.28, v2.8.29, v2.8.3, v2.8.30, v2.8.31, v2.8.32, v2.8.4, v2.8.5, v2.8.6, v2.8.7, v2.8.8, v2.8.9, v3.0.0, v3.0.1, v3.0.2, v3.0.3, v3.0.4, v3.0.5, v3.0.6, v3.0.7, v3.0.8, v3.0.9, v3.1.0, v3.1.1, v3.1.10, v3.1.2, v3.1.3, v3.1.4, v3.1.5, v3.1.6, v3.1.7, v3.1.8, v3.1.9, v3.2.0, v3.2.1, v3.2.10, v3.2.11, v3.2.12, v3.2.13, v3.2.14, v3.2.2, v3.2.3, v3.2.4, v3.2.5, v3.2.6, v3.2.7, v3.2.8, v3.2.9, v3.3.0, v3.3.1, v3.3.10, v3.3.11, v3.3.12, v3.3.13, v3.3.14, v3.3.2, v3.3.3, v3.3.4, v3.3.5, v3.3.6, v3.3.7, v3.3.8, v3.3.9, v3.4.0, v3.4.1].
- Can only install one of: symfony/process[v3.3.0, v4.0.1].
- Can only install one of: symfony/process[v3.3.1, v4.0.1].
- Can only install one of: symfony/process[v3.3.10, v4.0.1].
- Can only install one of: symfony/process[v3.3.11, v4.0.1].
- Can only install one of: symfony/process[v3.3.12, v4.0.1].
- Can only install one of: symfony/process[v3.3.13, v4.0.1].
- Can only install one of: symfony/process[v3.3.2, v4.0.1].
- Can only install one of: symfony/process[v3.3.3, v4.0.1].
- Can only install one of: symfony/process[v3.3.4, v4.0.1].
- Can only install one of: symfony/process[v3.3.5, v4.0.1].
- Can only install one of: symfony/process[v3.3.6, v4.0.1].
- Can only install one of: symfony/process[v3.3.7, v4.0.1].
- Can only install one of: symfony/process[v3.3.8, v4.0.1].
- Can only install one of: symfony/process[v3.3.9, v4.0.1].
- Installation request for symfony/process (locked at v4.0.1) -> satisfiable by symfony/process[v4.0.1].


Installation failed, reverting ./composer.json to its original content.

What exactly is going on here and why can't I globally install Valet? I realize it is probably some sort of dependency issue/conflict, but it doesn't make sense to me.

Symfony - An error occurred while loading the web debug toolbar

$
0
0

Since yesterday I dont see the sf-web-debugbar anymore.

I reverted all changes made since then - but the error stayed. I cleared cache, installed assets new. This error stays.

I can not see an error message - which tell me what is the problem.

enter image description here

enter image description here

enter image description here

the form which remains null symfony

$
0
0

I set up a search form with a handmade Entity but the form does not transmit the info to the entity ... you have an idea to solve this problem?

Also it's symfony 4.4 and I've already checked the findWeeklyPlanningRs query in the repository and it works fine.

this is the entity:

<?php

namespace App\Entity ;

class FilterWeek
{

  private $nbWeek ;


      public function getNbWeek(): ?int
      {
          return $this-> nbWeek;
      }

      public function setNbWeek(int $nbWeek): self
      {
          $this->$nbWeek = $nbWeek;

          return $this;
      }

}

the Controller

  /**
        * @Route("/{id}/week" ,  name="week")
        */

        public function weeklyPlanning(Request $request ,  $id ) : Response
        {

          $em = $this->getDoctrine()->getManager();

          $week = new FilterWeek();

          $form = $this -> createForm(FilterWeekType::class , $week ) ;
          $form->handleRequest($request);





          $planning = $em -> getRepository(Chargement::class) -> findWeeklyPlanningRs($id , $week-> getNbWeek()  ) ;

          $responsableSecteur = $em ->getRepository(ResponsableSecteur::class)->find($id) ;



          return $this -> render('Planing/ResponsableSecteurWeek.html.twig' , [
            'responsable_secteur' => $responsableSecteur,
            'chargements' => $planning ,
            'form' => $form -> createView()
            ] );

        }

the form :

<?php

namespace App\Form;

use App\Entity\FilterWeek;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;

class FilterWeekType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('nbWeek' , IntegerType::class , [

              'label' => 'numéro de la semaine' ,
              'required' => false
            ])
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => FilterWeek::class,
            'method' => 'get',
            'csrf_protection' => false,
        ]);
    }

    public function getBlockPrefix(){

      return '';
    }
}

the view :

{% extends 'base.html.twig' %}

{% block body %}

  <div class="container">

    <h3>Planning des chargements par Semaine</h3>

    <br><br>

    <div class="form-row">
      <div class="col-4">
        {{ form_start(form) }}
          {{ form_row(form.nbWeek) }}
            <button class="btn color-br"  style="top : 5em;">Rechercher</button>

        {{ form_end(form) }}
      </div>

How to enable plain id query rather than using paths in api_platform graphql?

$
0
0

I have implemented api_platform in my symfony 4 project, the problem is that I have to use the paths provided by the Rest api to fetch data using graphql like this

{
  user(id:"api/users/1")
  {
    id
  }
}

rather than

{
  user(id:1){
  id
  }
}

Went through the documentation and didn't find a solution for this. Using plain api paths in graph api isn't really worth moving to graphql. Any help.

Symfony 4.4 periodically empty response unless I clear the cache [closed]

$
0
0

I have a strange recurring issue in Symfony 4.4 (I am fairly new to Symfony 4): everything seems to work fine except sometimes (apparently randomly) the whole thing stops working. Without changing anything in the code if I clear the cache it all start working perfectly again. Did anyone experience something similar? (I am using FOSRestBundle and NelmioApiDoc building a simple microservice / rest api)

I have attached two screens: 1st before clearing the 2nd after clearing the cache. (the authorisation key changed in the call because i manually changed it)

Note the: "Type Error: Failed to fetch" in Nelmio Doc

Same with the curl response (empty response)

Works fine instantly after cache:clear

How to start local server with symfony 5 or downgrade version to 4.4?

$
0
0

I started a new project in new Symfony 5 and i can't open my local server.

On Symfony 4.4 the command PHP bin/console server:run is OK,

But with Symfony 5 the command appears not to be defined...

C:\Users\Chris\Code\api-test> php bin/console server:run
Command "server:run" is not defined.
Do you want to run "server:dump" instead?  (yes/no) [no]:

So how to downgrade or start the local server?

Best practice - How to respond with different entity views to improve performance in a RESTful API (Symfony 4) [closed]

$
0
0

When listing an using a REST index endpoint I would like to have different outputs for performance reasons.

ex: on the same GET path for CRUD indexing
- List of Entities with all associations
- List of Entities with some associations
- List of Entities with just some basic fields

This would be used for listing entities for a detailed view with statistics or just listing them for a drop down selector.

Possible Solution 1: I can do this in the controller by returning an object where I customize all the fields based on a query parameter - but then my controllers become very fat because listing all the required fields can be 20-30 fields per object. (basically giving up on the benefit of a serializer doing this automatically based on the type of the entity)

return [
   [
     'id' => $event->getId(),
     'name' => $event->getName(),
      ...
     'order_count' => $orderRepository->getOrderCountForEvent($event->getId())         
   ],
   ...
]

Possible Solution 2: I could define transform functions in the repository for the different views and filters that I want to return.

public function transform(Event $event, $type = 'shortlist')
{
    $view = null;

    switch($type) {
        case 'shortlist':
            $view = [
                'id'    => $event->getId(),
                'name'  => $event->getName(),
                'participants' => $orderRepository->getParticipantCountForEvent($event->getId()),
                 ...
            ];
        break;
        default:
            ... // all fields
        break
    }        

    return $view;
}

Are there any better / cleaner solutions? Most tutorials are only dealing with simple entities with simple relations and their CRUD implementations are very basic where they simply fetch every field and pass it to a serializer.


How to maintain and test a Symfony 4 bundle that has routes [closed]

$
0
0

I created several bundles that interacts between them. I had to create multiple of them and not just one project because each of them will be used in several project that are not related to each other.

So I did it and it works.

At the moment, they're in a project state and so, I linked them through path. It was a good option at the start of the project, because there was a lot of small correction/tests to do.

Now, this still works but it's not ideal because when I need to add a new functionnality, I need to launch the last project. Example, il have : project A < bundle B < bundle C.

If I want to update my bundle C, I need at least to launch my project A.

Even if it's not ideal, I can do it. But in a near future, I would like to add new functionnality and functionnal test it without launch everything, just working in my bundle.

There's plenty of tutorial to explain how to create the bundle, but not much to maintain them.

I looked in several huge bundle to check how they do :

I think the best answer I found was in EasyAdminBundle, there's a "tests/fixtures" folder. There, they create an App (with a Kernel, so it's a "real" app that can run on its own) and a AppTestBundle (that is a bundle). To be honnest, I don't understand why there's the AppTestBundle, but I think the App is what I look for, an application where I can test my main bundle modification.

What does my Bundle do :

  1. It has routes
  2. It has services (obviously)
  3. It has entities
  4. It gives a default configuration for other bundles

Maybe I'm on a complete wrong path, and I just need to create a new project with this bundle in it and test my bundle from that project but ... that is not what I have in mind when I want to test some code!

Hopefully, my unit tests work well, but I just want to be sure that my users can access (or not) to each page.

And I want to develop this bundle from within it! (and that, I'm really not sure how to do it).

EDIT : I can understand what I want is not obvious.

I will try to make it simple : When I have a bundle with some functionnality, how can I continue to develop it without including it in another project ? Is this even possible ?

With this question answered, I think I will be able to make some functionnal test on it (check the controllers, routes, ...).

Get the input values from twig file in Symfony Controller

$
0
0

I am trying to check the username entered to that stored in the database but the value I'm getting from the input in NULL when trying " var_dump($username);", what I'm doing wrong ?

Here is my controller Class

<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use App\Entity\Admin;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;

   class LoginController extends AbstractController
     {

    /**
      * @Route("/admin", name="admin")
 */
public function connect_admin(Request $request)
{

    $username= $request->query->get('username');

    $repository = $this->getDoctrine()->getRepository(Admin::class);


    $user =  $repository->findOneBy(['user' => $username]);

    var_dump($username);
    if ($user) {
        $message = "Success";
        echo "<script type='text/javascript'>alert('$message');</script>";
        return $this->render('site/admin.html.twig');

    }

   else{
    $message = "Try again";


    echo "<script type='text/javascript'>alert('$message');</script>";
   }


}



   }

The form:

<form class="login100-form validate-form flex-sb flex-w" method="GET" action="LoginController.php">

and this what did in the button href

<a class="login100-form-btn" name="button_save" id="button_save" href="{{ path('admin') }}">
                        Login
</a>

dunglas mercure server / javascript EventSource withCredentials : mercureAutorisation cookie not transmited

$
0
0

Making a mercure /hub dispaching Updates with symfony 4.4 works fine until I dont try using credentials with mercureAuthorization cookie.

As soon as I add {withCredentials: true} in EventSource, firefox kicks out event source request connection with "CORS missing" (whereas chrome doesn't)

'same origin' policy don't allow consulting 'http://localhost:3000/.well-known/mercure ... ' Reason: CORS header 'Access-Control-Allow-Origin' missing

Plus, I'm supposed to get the mercureAuthorization cookie passed from my page request to the event source request, but it isn't.

Here is my homePage cookie :

Set-Cookie: mercureAuthorization=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJtZXJjdXJlIjp7InN1YnNjcmliZSI6WyJodHRwOlwvXC9ub3RpZnkuY29tXC9wYXJhbmdvblwvdGVhbSJdfX0.e5YOGcOx-s-8nn2lbseqcVlk18dVEvgZIoKrDCEureA; path=/.well-known/mercure; httponly; samesite=strict;

My event source Request

Request URL: http://localhost:3000/.well-known/mercure?topic=http://notify.com/

No Set-Coockie indside.

EDIT: I finally manage to fix it by working on the same domain ! So know I run the mercure server with:

--adress:'www.mydomain.test:3000/.well-known/mercure ... '

Posting from

'www.mydomain.test/' for exemple

Set-Cookie:

'return new Cookie('mercureAuthorization', $token, 
  (exp) 0, 
  (path) '/.well-known/mercure', 
  (domain) null, 
  (secure) false, 
  (httponly) true, 
  (raw) false, 
  (same-site) 'Strict'
);'

How can I write custom annotation for any method of my project (not just Controllers) in Symfony 4?

$
0
0

How I write custom annotation for any method of my project (not just Controllers) in Symfony 4 ?

Symfony 4 debug production environments

$
0
0

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, exception logs etc.

Validating Botdetect recaptcha in Symfony 4 Without using an entity

$
0
0

Is there any way to validate a BotDetect recaptcha in the symfony form builder?

I have the below form, which lets a user enter their email.:

     $form = $this->createFormBuilder()
        ->add('email', EmailType::class,[
            'label' => false,
            'attr' => [
                'style' => 'text-align:center;',
                'value' => $email,
            ]
        ])
        ->add('captchaCode', CaptchaType::class, array(
            'captchaConfig' => 'ExampleCaptcha'
        ))
        ->add('Do some shiz wif my email bruh.', SubmitType::class)
        ->getForm();

    $form->handleRequest($request);

    if ($form->isSubmitted() && $form->isValid()) {
        return $this->redirect('/unblock/'.$email);
    }

The problem with this, is their documentation specifies a validation constraint in an Entity. My application does not have any entities (yet), but I would like to know if anyone has found a way to validate the captcha from the controller?

I'm fine with adding it to my entities when I create them , but I'm wondering how this would be done on an application that doesn't have any entities, or connection to a database.

FOSCKEditorBundle sometimes works and sometimes not , conflict with bootsnav.js

$
0
0

I'm using Symfony 4, and webPack encore bundle. I have a bizarre issue with Fosckeditorbundle, sometimes it works well and sometimes I get an error in the console, and I should refresh the browser many times until the bundle works.

FOSCkeditor bundle is not handled with Webpack Encore but the problem comes after using Webpack Encore bundle.

Uncaught TypeError: Cannot read property 'getClientRect' of null
at p.getClientRect (ckeditor.js:1253)
at p.queryViewport (ckeditor.js:1253)
at new p (ckeditor.js:1238)
at a.<anonymous> (ckeditor.js:1274)
at a.p (ckeditor.js:10)
at a.<anonymous> (ckeditor.js:12)
at a.CKEDITOR.editor.CKEDITOR.editor.fire (ckeditor.js:13)
at $.<anonymous> (ckeditor.js:944)
at ckeditor.js:30

EDIT:

I have made some tests and I have found that the problem comes from bootsnav.js, when I remove it, I have no error.


Symfony 4.4 returns empty response unless I clear the cache [closed]

$
0
0

Symfony 4.4.* stops working after editing code that doesn't change the cache (ex. adding a comment) and testing out routes. Everything works after clearing the cache but after a couple of calls it breaks again. This is sometimes non-specific or erratic.

The issue appears to be a caching problem caused by AH00052: child pid 67322 exit signal Segmentation fault (11) when running from the cache. For me it happened on PHP@7.4so downgrading to PHP@7.2 seems to be a temporary fix for now.

I am just mentioning this for anyone who might experience the same issue.

Script cache:clear returned with error code 255

$
0
0

I installed Symfony 4.2 via composer

composer create-project Symfony/website-skeleton my-project

everything works correctly, then I put the project in gitlab. a friend of mine tried to clone it on its own computer in order to work on the same project, and when he runs composer install

he got an error :

Script cache:clear returned with error code 255

Frankly, I tried everything I can find on the web and Stack Overflow but unfortunately, i didn't succeed.

Thanks in advance for any help

How to setup .env in Symfony for Reverse engineering using PDO

$
0
0

I just started a project with Symfony 4. In this project, I do not want to create my Entity but recover the existing database on an AS / 400. According to the doc Symfony, I have to reverse engineer but I have to complete the .env file with the information from my database namely: reverse_engineering

DATABASE_URL = mysql: // db_user: db_password@127.0.0.1: 3306 / db_name

However, the AS400 does not work with mysql but with DB2.

How can I make the bridge?

I'm thinking about using PDO, but I do not know how to make and modify my .env file.

Do you have an idea to help me?

Thanks for your help, If you need more information, just let me know.

Translate Symfony 4 / twig

$
0
0

I translate my string using the following instruction:

{% trans into lang %}hi{% endtrans %}

My doubt is, theres a way to translate strings inside a block? like this:

{{ include('user/_form.html.twig', {'button_label': 'Update'}) }}
<button class="btn  btn-primary submit-user"><i class="fa fa-edit"></i> {{ button_label|default('Save') }}</button>

I load the text from a external yaml.

Thanks

Kind regards.

Symfony 4 error "An exception occurred in driver: could not find driver"

$
0
0

Facing problem when typing php bin/console doctrine:database:create It returns an error I am on windows 10 Using Xampp VSCode editor

PS C:\app\xamp\htdocs\test> php bin/console make:migration In AbstractMySQLDriver.php line 106: An exception occurred in driver: could not find driver In PDOConnection.php line 31: could not find driver In PDOConnection.php line 27: could not find driver

In doctrine.yaml file: doctrine: dbal: driver: 'pdo_mysql' server_version: '5.7' charset: utf8mb4 default_table_options: charset: utf8mb4 collate: utf8mb4_unicode_ci url: '%env(resolve:DATABASE_URL)%' driver_class: App\DBAL\Driver\PDOMySql\Driver

    # IMPORTANT: You MUST configure your server version,
    # either here or in the DATABASE_URL env var (see .env file)
    #server_version: '5.7'
orm:
    auto_generate_proxy_classes: true
    naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
    auto_mapping: true
    mappings:
        App:
            is_bundle: false
            type: annotation
            dir: '%kernel.project_dir%/src/Entity'
            prefix: 'App\Entity'
            alias: App

In .env file: DATABASE_URL=mysql://root:@127.0.0.1:3306/testbrain?serverVersion=5.7

Thank you in advance for any answers

Viewing all 3925 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>