【问题标题】:Symfony2 components class not found找不到 Symfony2 组件类
【发布时间】:2015-04-27 22:53:18
【问题描述】:

我正在尝试在没有完整框架的情况下使用 Symfony2 的 RequestResponse 组件。这是我的代码:

<?php    
use Symfony\Component\HttpFoundation\Request;    
use Symfony\Component\HttpFoundation\Response;    
$r = Request::create( 'https://example.com', 'GET' );    
$response = $r->getResponse();    
$content = $response->getContent();

我得到这个错误:

PHP 致命错误:类 'Symfony\Component\HttpFoundation\Request' 在第 6 行的 /root/billing/web/index.php 中找不到

【问题讨论】:

标签: php symfony symfony-components


【解决方案1】:

您需要使用ClassLoader 组件来自动加载您的类,否则您必须改为require() 类文件。没有写自己的autoloader

参考“命名约定和自动加载”部分of this document

【讨论】:

    猜你喜欢
    • 2013-11-08
    • 2015-04-07
    • 2014-01-30
    • 2012-08-28
    • 2015-11-04
    • 2013-09-18
    • 2013-11-20
    • 2012-10-05
    • 1970-01-01
    相关资源
    最近更新 更多