Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
Sichere ProgrammierungStreamlining EV Customer Support using AI bots(28.09.2026 um 23:18 Uhr)
•
Sichere Programmierung7 Tools for Maintaining SaaS Infrastructure With a Small IT Team(30.09.2026 um 20:12 Uhr)
•
Sichere ProgrammierungHow to Implement Scoped Patient Consent in a FHIR API(30.09.2026 um 21:14 Uhr)
•
Sichere ProgrammierungAndroid System Design: A Complete Guide for Android Developers(01.10.2026 um 09:12 Uhr)
••
Sichere ProgrammierungWe Built a Trial Feature. A Customer Turned It Into a Referral System.(01.10.2026 um 09:16 Uhr)
•
Sichere ProgrammierungBring Your API: Building an MCP Server Builder(01.10.2026 um 09:16 Uhr)
•
Sichere ProgrammierungIntegration Digest for September 2026(01.10.2026 um 09:17 Uhr)
•••
Sichere ProgrammierungStreamlining EV Customer Support using AI bots(28.09.2026 um 23:18 Uhr)
•
Sichere Programmierung7 Tools for Maintaining SaaS Infrastructure With a Small IT Team(30.09.2026 um 20:12 Uhr)
•
Sichere ProgrammierungHow to Implement Scoped Patient Consent in a FHIR API(30.09.2026 um 21:14 Uhr)
•
Sichere ProgrammierungAndroid System Design: A Complete Guide for Android Developers(01.10.2026 um 09:12 Uhr)
••
Sichere ProgrammierungWe Built a Trial Feature. A Customer Turned It Into a Referral System.(01.10.2026 um 09:16 Uhr)
•
Sichere ProgrammierungBring Your API: Building an MCP Server Builder(01.10.2026 um 09:16 Uhr)
•
Sichere ProgrammierungIntegration Digest for September 2026(01.10.2026 um 09:17 Uhr)
•••
Intelligence View
⚡ tsecurity.de Intelligence

Symfony App Config in 2 steps

Customizing your Symfony application often involves tweaking configurations. For instance, enabling CSRF protection requires editing the framework.yaml file…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!

Customizing your Symfony application often involves tweaking configurations. For instance, enabling CSRF protection requires editing the framework.yaml file like this:




framework:
csrf_protection: true






These configurations, stored in the config/packages directory, come from third-party packages known as "Bundles." Each bundle can add its own configuration, identified by an extension alias (e.g., framework) and its settings (e.g., csrf_protection: true).



But what if you want to add custom configurations for your own application? Do you need to create a bundle for that? Not at all. Let me show you how to add your own application configuration in just 2 simple steps.






Step 1: Create an Extension Class



First, create an extension class to define your configuration. This class extends the Symfony\Component\DependencyInjection\Extension\AbstractExtension class and implements the configure() method:




<?php
namespace App\Extension;

use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\AbstractExtension;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

final class AppExtension extends AbstractExtension
{
public function configure(DefinitionConfigurator $definition): void
{
$definition->rootNode()
->children()
->booleanNode('some_toggle')->defaultFalse()->end()
->end()
;
}

public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void
{
$container->parameters()
->set('app.some_toggle', $config['some_toggle'])
;
}

public function getAlias(): string
{
return 'app';
}
}






Here, we've defined a configuration with a single boolean value called some_toggle (default is false). This is used later by the loadExtension() method to create a container parameter that can be injected into your services or controllers.



The getAlias() method is optional. By default, Symfony will guess the alias from the class name, so AppExtension becomes app. You only need to override it if you want to use a different extension alias, e.g. project_name instead of app.






Step 2: Register the Extension Class



Next, register this extension class in the container within your Kernel class’s build() method, so the container knows about it:




<?php

namespace App;

use App\Extension\AppExtension;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;

class Kernel extends BaseKernel
{
use MicroKernelTrait;

protected function build(ContainerBuilder $container): void
{
$container->registerExtension(new AppExtension());
}
}






And that’s it! Now you can add your own application configuration in a new config/packages/app.yaml file:




app:
some_toggle: true






I hope this guide helps you add custom configurations to your Symfony application. If you have any questions, feel free to ask in the comments below.

2. Cyber Threat Intelligence & Forensik

CTI Threat Relationship Graph2 Knoten / 1 Relationen
CVE / Incident Software MITRE ATT&CK CWE Weakness IoC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Symfony App Config in 2 steps

Thematisch verwandte Begriffe: Symfony, Config, steps · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag