Flag of Ukraine
SymfonyCasts stands united with the people of Ukraine

Desarrollo Armonioso con Symfony 6

2:23:48

What you'll be learning

// composer.json
{
    "require": {
        "php": ">=8.0.2",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "symfony/asset": "6.0.*", // v6.0.3
        "symfony/console": "6.0.*", // v6.0.3
        "symfony/dotenv": "6.0.*", // v6.0.3
        "symfony/flex": "^2", // v2.1.5
        "symfony/framework-bundle": "6.0.*", // v6.0.4
        "symfony/monolog-bundle": "^3.0", // v3.7.1
        "symfony/runtime": "6.0.*", // v6.0.3
        "symfony/twig-bundle": "6.0.*", // v6.0.3
        "symfony/ux-turbo": "^2.0", // v2.0.1
        "symfony/webpack-encore-bundle": "^1.13", // v1.13.2
        "symfony/yaml": "6.0.*", // v6.0.3
        "twig/extra-bundle": "^2.12|^3.0", // v3.3.8
        "twig/twig": "^2.12|^3.0" // v3.3.8
    },
    "require-dev": {
        "symfony/debug-bundle": "6.0.*", // v6.0.3
        "symfony/stopwatch": "6.0.*", // v6.0.3
        "symfony/web-profiler-bundle": "6.0.*" // v6.0.3
    }
}

Woh, ¡es la hora de Symfony 6! La mejor versión de Symfony, la más fluida y la más agradable hasta la fecha, ya sea que estés construyendo una API o un frontend con JavaScript. Ah, y también es la primera versión de Symfony hecha completamente para PHP 8.

Symfony 6 trata de agilizar tu experiencia de desarrollo, poniendo soluciones a tu alcance y ayudándote a disfrutar del proceso. Porque si se hace correctamente, programar es GENIAL.

En sus marcas, listos, ¡código!

  • Crea una nueva y elegante (¡pero diminuta!) aplicación Symfony que hará que tus amigos se sientan orgullosos
  • Instala y explora el binario symfony para obtener trucos de desarrollo
  • Prepara PhpStorm y los plugins para obtener la mejor experiencia
  • Aprende sobre Symfony Flex y el sistema de "recetas"
  • Instala paquetes y paquetes de terceros
  • Crea rutas y controladores (¡con atributos de PHP 8!)
  • La herramienta bin/consola
  • Twig y las plantillas
  • La barra de herramientas de depuración web: depuración insana al alcance de tu mano
  • Configuración de JavaScript y activos con Encore y Symfony UX
  • Crear un punto final de la API JSON y llamar mediante Ajax
  • Un vistazo a la parte más importante de Symfony: los servicios

¡Vamos amigos!


Your Guides

Ryan Weaver


Join the Conversation?

18
Login or Register to join the conversation
Yangzhi Avatar
Yangzhi Avatar Yangzhi | posted hace 1 año

can not wait anymore

3 Reply

no one can ;) stay tuned!

Reply
Salvadorrueda Avatar
Salvadorrueda Avatar Salvadorrueda | posted hace 10 meses

Awesome content. Thanks for sharing. Time to put it in practice.

2 Reply
Nizar Avatar

Hello,

could you put tutorials about elastic search and Symfony?
it is in high demand in the job market

2 Reply
Ruslan Avatar

Hi Ryan,
Could you make a course about testing? (Codeception).
Thank you.

2 Reply

Hey Ruslan!

Thank you for your interest in SymfonyCasts tutorials! We don't have any certain plans to cover Codeception in the nearest future unfortunately, but I add this topic to ours idea pool, thanks! Also, we're planning to brush up our tutorials about testing, i.e. PHPUnit, PhpSpec and Behat - most probably it will happen in 2022, but no any possible release date yet too. Meanwhile, in case you're interested in Testing tools, I'd recommend you to take a look at Testing track: https://symfonycasts.com/tr...

Cheers!

Reply
Ruslan Avatar

Thank you.
But if you will update "Testing tutorials", don't forget about Stimulus too, please.

1 Reply

Hey @Ruslan!

We’re definitely planning by on a big testing update - we need it!

About Stimulus - no update is needed there. Stimulus 3 is out, but other than a renamed package name and a few minor features, it is identical to v2. But if the tutorial is not making this fact obvious enough, please let me know!

Cheers!

1 Reply
Ruslan Avatar

I mean tests for App with Stimulus.

1 Reply

We will definitely be talking about that in those tutorials :)

1 Reply
Anthony-E Avatar
Anthony-E Avatar Anthony-E | posted hace 8 días

Hi, I wish there was a tutorial about deploying to platform.sh (apparently the recommended hosting service).

Reply

Hey @Anthony-E!

Sorry for the slow reply! It's something I'd like to do too - I'll add a vote for it on our internal tracker. If you'd like to see an example of a site deployed with platform.sh, you can see https://github.com/symfony/ux/tree/2.x/ux.symfony.com

Cheers!

Reply
montecarlocode Avatar
montecarlocode Avatar montecarlocode | posted hace 1 mes

Awesome course. I figured out symfony's power.

Reply

Woo! Keep up the good work 💪

Reply
Default user avatar

U type param string $slug = null, I think better way is to type like this ?string $slug = null, or string $slug = '', bacause '' == null but '' === null is not true.

Reply
Tom O. Avatar
Tom O. Avatar Tom O. | posted hace 1 año | edited

I am dynamically generating forms in Symfony 6. From the controller, I am calling a Form Type class in the traditional method. Therein, I am dynamically building some form fields based on the elements of the $options passed to the FormType class.

    public function index(Request $request): Response
    {
    // Entity is called Breed
    $data = new Breed();

    // I am passing these $options to the form
    $options = [
            'form_1'          => true,
            'form_2'          => false,
            'units'           => 'pounds'
            'form_3'          => false,
        ];

    $form = $this->createForm(BreedSurveyType::class, $data, $options);

In the BreedSurveyType form class, I am able to get my variables where I declare them in the configureOptions() method...

 public function configureOptions(OptionsResolver $resolver): void
    {
        $resolver->setDefaults([
            'data_class' => Breed::class,
            'form_1'          => false,
            'form_2'          => false,
            'units'              => null
            'form_3'          => false,
        ]);
    }

In the buildForm() method, I can access the $options, but I cannot if I embed a sub-form.

 public function buildForm(FormBuilderInterface $builder,array $options): void 
{
        // form_1          =   true
        // form_2          =   false
        // units           =  'pounds'
        // form_3          =   true

        if ($options['form_1'] === true) {
            $builder->add(
                    'name',
                    AnimalNameType::class
                );
        }

        if ($options['form_2'] === true) {
            $builder->add(
                    'sex',
                    AnimalSexType::class
                );
        }

        if ($options['form_3'] === true) {
            $builder->add(
                    'weight',
                    AnimalWeightType::class
                );
        }

.... in the parent-form, when I dump the $options variable,

array:59 [▼
  // snippet from web debug toolbar
  "form_1" => true
  "form_2" => false
  "units"  => "pounds"
  "form_3" => true
]

.... in the sub-form, when I dump the $options variable, I get the results from the declarations I made in the configureOptions() method.

array:59 [▼
  // snippet from web debug toolbar
  "form_1" => false
  "form_2" => false
  "units"  => null
  "form_3" => false
]

Effectively, is there a method to pass $options to a subform or do I need to isolate my logic of the dynamically created form in my BreedSurveyType class?

Thank you in advance.

Reply

Hey Tom O. !

Ah, I think I understand. By "sub form", you are referring to the AnimalNameType and other Animal###Type classes, right? If you want to pass options into those, you need to do it manually via the 3rd argument to ->add() For example. Suppose that you need to pass the units option into a sub-form:


public function buildForm(FormBuilderInterface $builder, array $options): void
{
    if ($options['form_1'] === true) {
        $builder->add(
            'name',
            AnimalNameType::class,
            ['units' => $options['units']]
        );
    }

    // ...
}

Of course, you'll need to make sure that AnimalNameType allows a units option in its configureOptions() method, but it sounds like you already have that.

Is that what you were referring to? If I completely missed the point, let me know :).

Cheers!

Reply
Cat in space

"Houston: no signs of life"
Start the conversation!

userVoice