themosis / theme

The Themosis framework theme.
http://framework.themosis.com/
GNU General Public License v2.0
104 stars 35 forks source link

Use composer packages in theme folder #12

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hi,

how should I call classes from packages installed in the theme's vendor folder?

Thank you for the help, Davide

jlambe commented 8 years ago

How did you load the framework? Using the themosis/themosis package? Normally when you register your package with composer, your classes are autoloaded and composer creates a vendor/autoload.php file which should be included inside your theme functions.php. Then simply call your classes like in the docs of your package.

ghost commented 8 years ago

Hi, I duplicated the themosis/theme and created a custom one. Yes I'm using themosis/themosis package. I would like to separate theme's packages from framework's packages. The only thing that I have to do is to include the vendor/autoload.php in my theme's function.php file?

jlambe commented 8 years ago

The best practice would be to define them in the theme and root composer.json files. Then simply run composer update at the root of your project. Defining packages inside the theme composer.json file will make sure that if you grab your theme on another project (later), composer will include your theme dependencies when it builds your new project. Now I recommand you to not run composer inside the theme as it is already available and loaded at the root of your project. You should define your package at root and simply use your classes inside your theme. It will be easier to maintain.

ghost commented 8 years ago

Ok, thank you for the exhaustive informations. That definitively answer my question!