Im trying to include some Symfony form components into my project.
use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormInterface;
If I do this I get :
Fatal error: Class 'Symfony\Component\Form\Form' not found
Even though I know that this is where the Form elements are. Using
require 'Symfony\Component\Form\Form.php'
works ,but I need to alias the form elements to get the class to work.
EDIT:
Trying this after copying the ClassLoader to the project still brings same error:
require_once __DIR__.'/Symfony/Component/ClassLoader/UniversalClassLoader.php';
use Symfony\Component\ClassLoader\UniversalClassLoader;
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
'Symfony' => __DIR__.'/Symfony',
));
$loader->register();
You need to set up autoloading. The ‘use’ does not do that for you. To do this, include the UniversalClassLoader, tell it where to load the Symfony files from and register it.
The ‘use’ statement just aliases the fully-qualified class name to a shorter version for you to use in that file.