
Magento 2.x – Constant name is expected. Error message.
When trying to run any bin/magento command, or just trying to access the site, and getting this error message.
The first thing you should try to get that solved, is identifying where the issue is.
To do so, i suggest digging into that file, and adding the corresponding log message, as follows:
file: vendor/magento/framework/Data/Argument/Interpreter/Constant.php
and add print_r($data);exit; before the throw, like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Framework\Data\Argument\Interpreter; use Magento\Framework\Data\Argument\InterpreterInterface; /** * Interpreter that returns value of a constant by its name */ class Constant implements InterpreterInterface { /** * {@inheritdoc} * @return mixed * @throws \InvalidArgumentException */ 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']); } } |
After that, you will see something like this:
So now, with that information, you will be able to understand which is the constant that needs to be fixed.
Hope this helps.
Enjoy!