Jump to content

How to setup Composer and use external libraries in ProcessWire


MoritzLost

Recommended Posts

I guess it could be a solution if composer require processwire/processwire only installed the wire-folder it the vendor-directory. While the installation/setup of the site-folder was a separate package.

It is my impression that @teppo uses composer a lot. Teppo, what do you think?

Link to comment
Share on other sites

On 3/9/2023 at 2:52 PM, MoritzLost said:

@eydun Yeah, but it's a bit involved. ProcessWire expects its core files in the webroot and won't work properly if they're inside the vendor folder. What you can do is use Composer scripts to hook into the Composer installation and put all of ProcessWire's files in place.

We're using a similar approach: install ProcessWire via Composer and then use post-install-cmd and post-update-cmd to copy the wire folder from vendor to web root. It would be preferable not to have to do the whole post-[install/update]-cmd step (or have entire wire directory in public directory for that matter) but to be honest this works quite well.

Some files in wire need to be web accessible, so I'm not aware of any clean way around this.

To be clear this is about installing and/or updating ProcessWire on a site that has already been set up. As for setting up a complete, new ProcessWire setup via Composer... I've no experience about that. Technically you could install ProcessWire via Composer and then copy everything from vendor/processwire/processwire/ to your web root, but for my use cases that has never really made sense 🙂

  • Like 2
Link to comment
Share on other sites

Thank you for the reply.

If the "wire"-folder did not have to be accessible from public, then it would perhaps make sense to split the installation-process of "wire" and "site" into two steps. The first step could be handle by composer, while I am not so sure how to best handle the latter...

Link to comment
Share on other sites

On 3/18/2023 at 12:15 AM, eydun said:

If the "wire"-folder did not have to be accessible from public, then it would perhaps make sense to split the installation-process of "wire" and "site" into two steps. The first step could be handle by composer, while I am not so sure how to best handle the latter...

For our starter kit for new projects, we used Site Profile Exporter to include a database dump in the site folder. While working on that folder, everything was inside the site folder. When we set up a new project based on that starter kit, we use Composer commands to rename that folder to something like site-starterkit. This is recognized by ProcessWire as a site profile, so we can normally install ProcessWire using that site profile, at which point it will be renamed to site again.

Link to comment
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...