2

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

Tom Tom
  • 3,680
  • 5
  • 35
  • 40
  • 3
    After you solve the class loading issue, you will have to deal with the fact that Request has no getResponse method. Consider using a framework (Silex,Laravel,Symfony 2) to at least understand the basics. Or maybe: https://github.com/fabpot/Create-Your-Framework/blob/master/book/part01.rst. – Cerad Feb 25 '15 at 19:33

1 Answers1

1

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

Tom Tom
  • 3,680
  • 5
  • 35
  • 40