安装后出现Symfony 2.8.1错误

时间:2016-01-04 13:29:45

标签: php symfony

我正在使用 Symfony 2.8.1 并使用 WAMP Server 2 Apache 2.4.2 处理 Windows 8 和PHP 5.4.3 我已成功使用命令工具安装Symfony,但当我尝试访问网址 http://localhost/Symfony/web/app_dev.php/ 时,收到以下错误消息:

FatalErrorException in ProxyGenerator.php line 62: Parse Error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING)

然后是这个错误列表:

in ProxyGenerator.php line 62
at DebugClassLoader->loadClass() in EntityManager.php line 0
at ProxyFactory->__construct() in EntityManager.php line 166
at EntityManager->__construct() in EntityManager.php line 850
at EntityManager::create() in appDevDebugProjectContainer.php line 605
at appDevDebugProjectContainer->getDoctrine_Orm_DefaultEntityManagerService() in Container.php line 312
at Container->get() in classes.php line 6695
at ManagerRegistry->getService() in classes.php line 6665
at AbstractManagerRegistry->getManagers() in DoctrineDataCollector.php line 65
at DoctrineDataCollector->collect() in Profiler.php line 218
at Profiler->collect() in ProfilerListener.php line 128
at ProfilerListener->onKernelResponse() in WrappedListener.php line 61
at call_user_func() in WrappedListener.php line 61
at WrappedListener->__invoke() in classes.php line 1853
at call_user_func() in classes.php line 1853
at EventDispatcher->doDispatch() in classes.php line 1771
at EventDispatcher->dispatch() in TraceableEventDispatcher.php line 132
at TraceableEventDispatcher->dispatch() in HttpKernel.php line 179
at HttpKernel->filterResponse() in HttpKernel.php line 161
at HttpKernel->handleRaw() in HttpKernel.php line 62
at HttpKernel->handle() in ContainerAwareHttpKernel.php line 69
at ContainerAwareHttpKernel->handle() in Kernel.php line 185
at Kernel->handle() in app_dev.php line 30
at {main}() in app_dev.php line 0

在ProxyGenerator.php的第62行:

protected $placeholders = [
    'baseProxyInterface'   => Proxy::class,
    'additionalProperties' => '',
];

问题似乎是这样:

Proxy::class

当我将其更改为:

'Doctrine\Common\Proxy\Proxy'

有效!

我想知道发生了什么,以及我所做的改变是否真的是一个解决方案。

有什么想法? 感谢。

3 个答案:

答案 0 :(得分:5)

这是 PHP 版本问题。您至少需要 PHP 5.5

这是因为class使用静态server { listen 80; listen [::]:80; root /var/www/html/clocks.si/public_html; index index.php index.html index.htm; server_name clocks.si; location / { try_files $uri $uri/ /index.php; } location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi.conf; } #deny access to .htaccess files, if Apache's document root #concurs with nginx's one location ~ /\.ht { deny all; } } 关键字进行类名解析。

因此,将 Wamp 服务器更新为 PHP> 5.5 ,你应该好好去!

资料来源: here

答案 1 :(得分:5)

您可以运行composer update重新安装与您的PHP版本兼容的供应商库版本。

答案 2 :(得分:0)

Symfony 2.8与PHP 5.3.9或更高版本兼容。但是,Symfony使用的一个名为Doctrine的外部库需要PHP 5.5或更高版本。

目前唯一的解决方案是更新PHP安装。在下一个Symfony 2.8.x版本中,这可以通过限制用于Doctrine库的版本来解决。