Using Composer to Manage WP Projects (Incomplete)

Brian Kelleher
Brian Kelleher
Last updated 

Available Repos


Add the UComm Packages Repo to your Local Composer

You can add the UConn Packages repo to your global composer configuration so that you don't need to specify the --repository-url parameter when starting a new project. This only needs to be done one time.
composer config -g repositories.ucomm '{"type": "composer", "url": "https://packages.ucdev.net/"}'


Starting a new WordPress project (site, plugin or theme)

This will create a new project by using the ucomm/wp-project-boilerplate git repo as the boilerplate. 

Site
$ composer create-project ucomm/wp-project-boilerplate <new-site-name>

Plugin
$ composer create-project ucomm/wp-plugin-project-boilerplate <new-plugin-name>

Theme
$ composer create-project ucomm/wp-theme-project-boilerplate <new-theme-name>

After the project has scaffolded, we need to update the configuration for your new project.
$ cd <new-project-name>

Before the next command, remove the composer.lock file from .gitignore so that it's checked in to source control.

Some of the themes/plugins have extra build steps that are not yet resolved by the initial composer create project.  They should eventually be fixed, to work, but running an install will build and pull in any extra dependencies.
$ composer install

You can modify the composer.json file directly or edit values from the CLI. Name should follow the form of <vendor>/<name>, just like within bitbucket or github.
$ composer config name ucomm/my-new-plugin

Update the composer.json file with any plugins that you need from UComm Packages or WPackagist. For example, this would install Yoast SEO and update composer.json. As always, you can manually update composer.json.
$ composer require wpackagist-plugin/wordpress-seo

Make sure to also edit the description and add any other necessary data to the composer.json file to help other team members identify projects.

Setting up Docker Compose

You will then want to get your docker-compose file ready for development.  You can test the initial install with:
$ docker-compose up
but this will map your dependencies and not your actual project.  You will need to add a volume that looks like the following to the web service in docker-compose.yml:
./:/var/www/html/content/{themes,plugins}/{plugin,theme name}
Check an existing composer repository for examples.
If a dev dependency (e.g. lobo or castor) requires access to the vendor folder, you can map it in the following way
./vendor:/var/www/html/content/themes/lobo/vendor

Bitbucket Pipelines

There is a bitbucket-pipelines.yml file supplied in this repository root.  If you enable bitbucket pipelines in the project repository, the repo will automatically build a new ZIP download for the develop branch (when pushing to develop), and the most recent tag available when pushing to the master branch.  Make sure to push tags before master!  You will also need to set a BB_AUTH_STRING pipelines env variable in order for this to work.

Update ReadMe

Please update the README.md file provided in your new project.  This will be beneficial to others developing your package.

Remember to Update packages.ucdev.net

When you push a new version of this new composer package, make sure than an update is run "Composer Package Management/Build Composer Repository" jenkins task.  This will push changes to inetserve, thus updating packages.ucdev.net with the most recent tag for your package.  In the future this might be automated (: