Is there a way to get the composer autoloader instance inside a Symfony2 Controller?
Symfony2 - Composer class loader instance in controller
470 views Asked by Steffen Brem At
        	2
        	
        There are 2 answers
0
                
                        
                            
                        
                        
                            On
                            
                            
                                                    
                    
                Using the $GLOBALS did not work for me, but you can also get it like this:
$autoload_functions = spl_autoload_functions();
$loader = $autoload_functions[0][0];
this assumes that "autoload.php" has been required, AND that it is configured to prepend the composer classloader to other classloaders (the default).
NOTE: I am not saying this is good style.
Yes - there is a way.
And assuming that you want to know how to actually get the loader then you can do this in your controller:
Should you do this? Probably not. In most cases you can tweak the loader in the app/autoload.php file.