问题
I just installed Symfony on my CentOS setup running with PHP 7.0.14. I am however having the following issue when trying to run symfony new project_name
:
PHP Notice: Use of undefined constant JSON_ERROR_DEPTH - assumed 'JSON_ERROR_DEPTH' in phar:///usr/local/bin/symfony/vendor/guzzlehttp/guzzle/src/Utils.php on line 134
PHP Notice: Use of undefined constant JSON_ERROR_STATE_MISMATCH - assumed 'JSON_ERROR_STATE_MISMATCH' in phar:///usr/local/bin/symfony/vendor/guzzlehttp/guzzle/src/Utils.php on line 134
PHP Notice: Use of undefined constant JSON_ERROR_CTRL_CHAR - assumed 'JSON_ERROR_CTRL_CHAR' in phar:///usr/local/bin/symfony/vendor/guzzlehttp/guzzle/src/Utils.php on line 134
PHP Notice: Use of undefined constant JSON_ERROR_SYNTAX - assumed 'JSON_ERROR_SYNTAX' in phar:///usr/local/bin/symfony/vendor/guzzlehttp/guzzle/src/Utils.php on line 134
PHP Notice: Use of undefined constant JSON_ERROR_UTF8 - assumed 'JSON_ERROR_UTF8' in phar:///usr/local/bin/symfony/vendor/guzzlehttp/guzzle/src/Utils.php on line 134
PHP Fatal error: Uncaught Error: Call to undefined function json_decode() in phar:///usr/local/bin/symfony/vendor/guzzlehttp/guzzle/src/Utils.php:142
Stack trace:
#0 phar:///usr/local/bin/symfony/vendor/guzzlehttp/guzzle/src/Message/Response.php(145): GuzzleHttp\Utils::jsonDecode('{"lts":"2.8.18"...', true, 512, 0)
#1 phar:///usr/local/bin/symfony/src/Symfony/Installer/NewCommand.php(127): GuzzleHttp\Message\Response->json()
#2 phar:///usr/local/bin/symfony/src/Symfony/Installer/NewCommand.php(65): Symfony\Installer\NewCommand->checkSymfonyVersionIsInstallable()
#3 phar:///usr/local/bin/symfony/vendor/symfony/console/Command/Command.php(259): Symfony\Installer\NewCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 phar:///usr/local/bin/symfony/vendor/symfony/console/Application.php(878): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 phar:///us in phar:///usr/local/bin/symfony/vendor/guzzlehttp/guzzle/src/Utils.php on line 142
I've checked around the web for answers, and have already tried setting phar.readonly = Off
in php.ini
回答1:
Hassan was right, I was missing the json-extension. Fixed it by running sudo yum install php70u-json
来源:https://stackoverflow.com/questions/43140962/json-error-when-adding-symfony-app