Jump to content

Using composer and namespace in prestashop 1.6


Recommended Posts

  • 1 month later...

There are a number of ways you could do that. One that I think makes a lot of sense is to require Composer’s autoload file from the primary PrestaShop Controller abstract class, which is inherited by all other controllers.
Here’s how to do so:

  • Create a file named Controller.php  in  override/classes/controller/
  • Paste this code into that file:
 * Override the main Controller abstract class to require Composer's autoload file
 * Makes Composer packages available to your entire PrestaShop install
abstract class Controller extends ControllerCore
	public function __construct()
		// Load Composer vendor packages
		require _PS_ROOT_DIR_ . '/vendor/autoload.php';


Note: after saving the override, make sure to delete the class cache file, located at cache/class_index.php .

Edited by acusti (see edit history)
  • Like 1

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More