I am receiving this error:

Uncaught exception 'InvalidArgumentException' with message 'Constant name is expected.

While running php bin/magento setup:upgrade in command line.

i got this http://awesomescreenshot.com/0535zi4648 error.


I think some problem in your etc folder. check all xml files. Constant name should be in CAPITAL letters. any of your constant remain in small letters. check it and correct it. Hope this will solve your Problem.


In order to help you debug what's going on, I would suggest to temporary edit the file


From this...

public function evaluate(array $data) {
    if(!isset($data['value']) || !defined($data['value'])) {
        throw new \InvalidArgumentException('Constant name is expected.');
    return constant($data['value']);

To this...

public function evaluate(array $data) {
    if(!isset($data['value']) || !defined($data['value'])) {
        print_r($data);exit;                                                    // <<<<<<<<<<<<
        throw new \InvalidArgumentException('Constant name is expected.');
    return constant($data['value']);

Thereby you will be notified of which class / constant is causing you the error :

enter image description here

Hope it could help someone else ;-) See ya


In a case when your extension is in app/code folder you will get this error if your folder name is different than module name after Magento_ in module.xml

for an example: if your module name is Magento_MyGreatModule your folder name must be MyGreatModule.

  • thank you ! another great example of misleading error msg ... – medmek Jun 23 '18 at 15:46
  • This answer worked for me as well. – Arfeen Jul 26 '18 at 10:03
  • Thank you! Bumped into this one after I renamed my module. – Giel Berkers Nov 27 at 10:57

Like already stated in the previous answers, this is most likely because some error in one of your configuration files. For instance, this error is triggered when you do the following without having a class that declares the constant (notice the ::CODE declaration):

<!-- etc/di.xml -->
<virtualType name="ExamplePaymentGatewayConfig" type="Magento\Payment\Gateway\Config\Config">
    <argument name="methodCode" xsi:type="const">\Company\Example\Model\Ui\ConfigProvider::CODE</argument>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.