Writing a new module and in my system.xml I can put the following:
<field id="environment" translate="label" type="select" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Environment</label>
<source_model>Magento\Config\Model\Config\Source\Enabledisable</source_model>
</field>
And I get a select input with two options, Enable and Disable.
If I write my own Source class, and put the correct class namespace path, I get the following error:
Exception #0 (ReflectionException): Class Vendor\Module\Model\Config\Source\Environment does not exist
Environment.php
<?php
namespace Vendor\Module\Model\Config\Source;
use Magento\Framework\Data\OptionSourceInterface;
class Environment implements OptionSourceInterface
{
public function toOptionArray()
{
return [
['value' => 0, 'label' => __('Sandbox')],
['value' => 1, 'label' => __('Production')]
];
}
}
Updated system.xml field
<field id="environment" translate="label" type="select" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Environment</label>
<source_model>Vendor\Module\Model\Config\Source\Environment</source_model>
</field>