Roots Discourse

Autoloading in bedrock

I am using bedrock for the first time and I have setup a child theme in it. I want to know how to add a class in the theme so it is autoloaded just like how the rest of bedrock is working.

1 Like
  1. set up composer autoloads in your child theme
  2. require the composer autoloader in your child theme, example: https://github.com/roots/sage/blob/36937b4ceafb9b3c5b705be2ad6f75bc77a9efce/functions.php#L14

Note: This is unrelated to bedrock. You can use this technique on non-bedrock projects.

See also: https://roots.io/namespacing-and-autoloading/

4 Likes

Thanks :slight_smile:

This topic was automatically closed after 42 days. New replies are no longer allowed.