Magento2 – system.xml

In this blog post we will see how to setup System Configuration for your module in magento2

System configuration in magento2 is very similar to magento1, so you read basics of system configuration in magento here

System configuration is divided into different parts; tab, section, group and field which is described in magento1 blog. This same concepts are used in magento2 as well.

The system.xml file is located in adminhtml/ folder in magento2


add the content is

<?xml version="1.0"?>
<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
        <tab id="helloworld" translate="label" sortOrder="100"> 
            <!-- add a new tab with id helloworld -->
            <label>Hello World</label>
        <section id="helloworld" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
            <!-- add a new section with id helloworld and for tab helloworld -->
            <label>Hello World Configuration</label>
            <group id="active_display" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
                <!-- add a new group with id active display -->
                <label>Hello World Configuration Options</label>
                <field id="scope" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
                    <!-- add a new field with id scope -->
                    <label>Enable Helloworld Controller</label>

Above we can see how to add a new tab, section, group and field

Next to set default values for these configuration item, create the file


and add the code

<?xml version="1.0"?>
<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">

There is another important thing to do, in our system.xml we had the line


This is used to setup ACL for system configration. How this works in detail we will see later, but for now create the file


with the code

<?xml version="1.0"?>
<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
            <resource id="Magento_Adminhtml::admin">
                <resource id="Magento_Adminhtml::stores">
                    <resource id="Magento_Adminhtml::stores_settings">
                        <resource id="Magento_Adminhtml::config">
                            <resource id="Excellence_First::test_config" title="Hello World Section" />

Now when you open magento admin, you see the HelloWorld tab and sections.
You might get an error 404 Not Found first time, just logout and login again to fix this

If you want to explore further system configuration options which magento2 provides, look at the module Magento/Config/Model/Config files. Here you can see other system configuration options which magento provides. You can also explore other system.xml files from core magento modules .