OSx php7.1 个问题

OSx php7.1 problems

我是 OSx 的新手,我的 php 安装和 SPL 功能有问题。有时,当我尝试通过 apache 访问 symfony 项目时,出现如下所示的错误。

当 spl_autoloader 尝试加载 ParameterBag class 时:

Warning: class_implements(): Class /.[^.]+.twig$/ does not exist and could not be loaded

堆栈跟踪:

1 in DebugClassLoader.php line 243
2 at ErrorHandler->handleError('2', 'class_implements(): Class /\.[^.]+\.twig$/ does not exist and could not be loaded', '/Users/mtertishniy/sites/dvsota/vendor/symfony/symfony/src/Symfony/Component/Debug/DebugClassLoader.php', '243', array('class' => 'Symfony\Component\HttpFoundation\ParameterBag', 'file' => '/Users/mtertishniy/sites/dvsota/vendor/composer/../symfony/symfony/src/Symfony/Component/HttpFoundation/ParameterBag.php', 'exists' => true, 'refl' => object(ReflectionClass), 'name' => 'Symfony\Component\HttpFoundation\ParameterBag', 'notice' => array(), 'len' => '8', 'ns' => 'Symfony\', 'parent' => false, 'parentInterfaces' => array('/\.[^.]+\.twig$/' => '1'), 'deprecatedInterfaces' => array(), 'interface' => '/\.[^.]+\.twig$/'))
3 at class_implements('/\.[^.]+\.twig$/') in DebugClassLoader.php line 243
4 at DebugClassLoader->loadClass('Symfony\Component\HttpFoundation\ParameterBag')
5 at spl_autoload_call('Symfony\Component\HttpFoundation\ParameterBag') in Request.php line 247

其他奇怪的错误:

OutOfMemoryException in DebugClassLoader.php line 243:

Error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 140495632205216 bytes)

我调试了这个错误,发现在这种情况下自动加载器试图加载格式错误的接口:

我已经从 brew 安装了 httpd 和 PHP 7.1。

我的 php 个模块:

$ php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
imagick
intl
json
ldap
libxml
mbstring
mcrypt
mysqli
mysqlnd
odbc
openssl
pcntl
pcre
PDO
pdo_mysql
PDO_ODBC
pdo_sqlite
Phar
posix
readline
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xdebug
xml
xmldiff
xmlreader
xmlrpc
xmlwriter
xsl
yaml
zip
zlib

[Zend Modules]
Xdebug

如何解决这个问题?

因为你的限制很大

您正在尝试分配 140495GB 的数据。

您要么需要:

  • 重新考虑您的应用程序需要多少内存(推荐)
  • 将内存限制增加到 140495GB(不推荐)。

尝试分配 128MB 到 256MB ... 数据。

我终于明白了!这是核心 php < 7.2 中的错误。 https://bugs.php.net/bug.php?id=74015

问题已关闭。