After I executed the CLI commands showing an below error
When I'm trying to access front end admin panel throwing an below error.
Fatal error: Uncaught InvalidArgumentException: Constant name is expected. in /var/www/html/vendor/magento/framework/Data/Argument/Interpreter/Constant.php:23 Stack trace: #0 /var/www/html/vendor/magento/framework/Data/Argument/Interpreter/Composite.php(61): Magento\Framework\Data\Argument\Interpreter\Constant->evaluate(Array) #1 /var/www/html/vendor/magento/framework/ObjectManager/Config/Mapper/Dom.php(102): Magento\Framework\Data\Argument\Interpreter\Composite->evaluate(Array) #2 /var/www/html/vendor/magento/framework/Config/Reader/Filesystem.php(176): Magento\Framework\ObjectManager\Config\Mapper\Dom->convert(Object(DOMDocument)) #3 /var/www/html/vendor/magento/framework/Config/Reader/Filesystem.php(132): Magento\Framework\Config\Reader\Filesystem->_readFiles(Object(Magento\Framework\Config\FileIterator)) #4 /var/www/html/vendor/magento/framework/App/ObjectManager/ConfigLoader.php(76): Magento\Framework\Config\Reader\Filesystem->read('global') #5 /var/www/html/vendor/magento/framework/App/ObjectManager/Environment/Deve in /var/www/html/vendor/magento/framework/Data/Argument/Interpreter/Constant.php on line 23
/var/www/html/vendor/magento/framework/Data/Argument/Interpreter/Constant.php
The code
<?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'])) { throw new \InvalidArgumentException('Constant name is expected.'); } return constant($data['value']); } }
Solved! Go to Solution.
Finally I solved this error.
Do like this from:
<?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'])) { throw new \InvalidArgumentException('Constant name is expected.'); } return constant($data['value']); } }
To:
<?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']); } }
You will notify from where you getting an error, now change it accordingly and re-fresh.
No I'm able to run the CLI commands and front-end also working fine.
Finally I solved this error.
Do like this from:
<?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'])) { throw new \InvalidArgumentException('Constant name is expected.'); } return constant($data['value']); } }
To:
<?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']); } }
You will notify from where you getting an error, now change it accordingly and re-fresh.
No I'm able to run the CLI commands and front-end also working fine.
In my case the error was a letter case issue in the path of the class that was holding the constant value.
On Windows the path works fine becasue folder names are "case insensitive", but then when I installed the module on Linux, the folder name was not found becase folder/file names are "case sentive" in this env.