Hassan Refaat
Hassan Refaat

Reputation: 31

Symfony2 components class not found

I am trying to use the Request & Response components of Symfony2 without the full framework. Here is my code:

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

And I get this error :

PHP Fatal error: Class 'Symfony\Component\HttpFoundation\Request' not found in /root/billing/web/index.php on line 6

Upvotes: 2

Views: 1365

Answers (1)

Tom Tom
Tom Tom

Reputation: 3698

You need to use the ClassLoader component to autoload your classes or you'll have to require() the class files instead. Short of writing your own autoloader.

Refer to the "Naming Conventions and Autoloading" part of this document

Upvotes: 1

Related Questions