Skip to content

Commit b650176

Browse files
authored
Improve composer installation instructions
1 parent f686a13 commit b650176

File tree

1 file changed

+58
-38
lines changed

1 file changed

+58
-38
lines changed

architecture/using-composer.md

Lines changed: 58 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: "Architecture Concepts: Composer"
3+
description: "Documentation on using Composer within Winter CMS projects."
4+
---
5+
16
# Using Composer
27

38
## Introduction
@@ -6,56 +11,34 @@ Using [Composer](https://getcomposer.org/) as an alternative package manager to
611

712
Composer is the de-facto standard for package management in the PHP ecosystem, and can handle the downloading, installation and management of Winter CMS plugins and themes, as well as third-party Laravel packages and vendor libraries.
813

9-
### Missing `composer.json`?
10-
11-
If you have created your Winter CMS project recently, using either Composer or the Web Installer, then you should have a `composer.json` present in your proejct root.
12-
13-
If you are missing your `composer.json` file, simply copy the latest [`composer.json`](https://github.com/wintercms/winter/tree/develop/composer.json) file from [GitHub](https://github.com/wintercms/winter/tree/develop) into your Winter instance and then run `composer install` within the root directory of the project.
14-
15-
> **NOTE:** If you have made modifications to the files within the `modules` directory, these will be overwritten by Composer if an update to those modules is installed. It is recommended that you *do not* make modifications to the modules directly.
16-
17-
### Development branch
18-
19-
If you plan on submitting pull requests to the Winter CMS project via GitHub, or are actively developing a project based on Winter CMS and want to stay up to date with the absolute latest version, we recommend switching your composer dependencies to point to the `develop` branch where all the latest improvements and bug fixes take place. Doing this will allow you to catch any potential issues that may be introduced (as rare as they are) right when they happen and get them fixed while you're still actively working on your project instead of only discovering them several months down the road if they eventually make it into production.
20-
21-
```json
22-
"winter/storm": "dev-develop as 1.2.999",
23-
"winter/wn-system-module": "dev-develop as 1.2.999",
24-
"winter/wn-backend-module": "dev-develop as 1.2.999",
25-
"winter/wn-cms-module": "dev-develop as 1.2.999",
26-
"laravel/framework": "~9.0",
27-
```
28-
29-
> **NOTE:** Do not commit the changes to `composer.json`, as this file is handled by the Winter CMS maintainers.
30-
31-
### Deployment best practices
32-
33-
Using the following best practices with Composer and Winter CMS will make deployment of your Winter CMS installation much smoother:
34-
35-
- Store the `composer.lock` file in your source control. This file is ignored by Git by default in the `.gitignore` file included by Winter CMS, but should be deployed with your application to speed up the install and update process.
36-
- Add a `.gitignore` file inside the `modules` folder to ignore all changes within this folder, as the modules will be installed and updated by Composer.
37-
- Add a `.gitignore` file inside the `plugins` folder to ignore all changes within this folder if you install your plugins via Composer. You can optionally allow custom plugins that are only being used for that specific project.
38-
- Use `composer install --no-dev` on your production instance to specifically exclude any "development" packages and libraries that won't be used in production.
39-
4014
## Installing Winter via Composer
4115

4216
Installing Winter via Composer is easy. You can use the `create-project` command through Composer to quickly set up a new Winter installation.
4317

4418
```bash
45-
composer create-project wintercms/winter <your installation directory>
19+
composer create-project wintercms/winter <your installation directory> [version]
4620

4721
# Example:
4822
# composer create-project wintercms/winter mywinter
23+
# or
24+
# composer create-project wintercms/winter ./ "dev-develop"
4925
```
5026

51-
If you wish to install a specific version of Winter, you can also specify the version.
27+
### Configuring Winter
5228

53-
```bash
54-
composer create-project wintercms/winter <your installation directory> "<version>"
29+
If you have used `create-project` to create your Winter project it will automatically run the following commands for you:
5530

56-
# Example:
57-
# composer create-project wintercms/winter mywinter "1.0.474"
58-
```
31+
- [`winter:install`](../console/setup-maintenance#install-winter-via-command-line) (the CLI installation wizard)
32+
- [`winter:env`](../console/setup-maintenance#configure-winter-through-an-environment-file) (populates the `.env` file from the configuration files)
33+
- [`winter:mirror public --relative`](../console/setup-maintenance#mirror-public-files) (sets up the project to use a public folder, recommended for security)
34+
35+
You can either go through this wizard to configure your project or you can cancel with (`Ctrl+C`) and manually reviewing and make changes to the configuration files located in `config/*.php`. If you take the manual approach, note that you will also need to run `php artisan migrate` to migrate the database yourself after configuring the project.
36+
37+
> **NOTE:** When running commands on your Winter project, make sure that you are located in the project root directory first (following the previous example you can run `cd mywinter`).
38+
39+
### Completing installation
40+
41+
Once the above commands have been run, refer to the [Post Installation steps](../setup/installation#post-installation-steps) on the Installation page to complete the process.
5942

6043
## Installing a plugin or theme using Composer
6144

@@ -88,6 +71,41 @@ composer require --dev <your package name> "<version constraint>"
8871
# composer require --dev winter/wn-builder-plugin "^2.0.0"
8972
```
9073

74+
After installing any packages via composer it is important to ensure that any included migrations are run and if you are [using a public folder](../setup/configuration#using-a-public-folder) that the public folder is regenerated. Use the following commands to accomplish that:
75+
76+
```bash
77+
php artisan migrate && php artisan winter:mirror public --relative
78+
```
79+
80+
### Missing `composer.json`?
81+
82+
If you have created your Winter CMS project recently, using either Composer or the Web Installer, then you should have a `composer.json` present in your proejct root.
83+
84+
If you are missing your `composer.json` file, simply copy the latest [`composer.json`](https://github.com/wintercms/winter/tree/develop/composer.json) file from [GitHub](https://github.com/wintercms/winter/tree/develop) into your Winter instance and then run `composer install` within the root directory of the project.
85+
86+
> **NOTE:** If you have made modifications to the files within the `modules` directory, these will be overwritten by Composer if an update to those modules is installed. It is recommended that you *do not* make modifications to the modules directly.
87+
88+
### Development branch
89+
90+
If you plan on submitting pull requests to the Winter CMS project via GitHub, or are actively developing a project based on Winter CMS and want to stay up to date with the absolute latest version, we recommend switching your composer dependencies to point to the `develop` branch where all the latest improvements and bug fixes take place. Doing this will allow you to catch any potential issues that may be introduced (as rare as they are) right when they happen and get them fixed while you're still actively working on your project instead of only discovering them several months down the road if they eventually make it into production.
91+
92+
```json
93+
"winter/storm": "dev-develop as 1.2.999",
94+
"winter/wn-system-module": "dev-develop as 1.2.999",
95+
"winter/wn-backend-module": "dev-develop as 1.2.999",
96+
"winter/wn-cms-module": "dev-develop as 1.2.999",
97+
"laravel/framework": "~9.0",
98+
```
99+
100+
### Deployment best practices
101+
102+
Using the following best practices with Composer and Winter CMS will make deployment of your Winter CMS installation much smoother:
103+
104+
- Store the `composer.lock` file in your source control. This file is ignored by Git by default in the `.gitignore` file included by Winter CMS, but should be deployed with your application to speed up the install and update process.
105+
- Add a `.gitignore` file inside the `modules` folder to ignore all changes within this folder, as the modules will be installed and updated by Composer.
106+
- Add a `.gitignore` file inside the `plugins` folder to ignore all changes within this folder if you install your plugins via Composer. You can optionally allow custom plugins that are only being used for that specific project.
107+
- Use `composer install --no-dev` on your production instance to specifically exclude any "development" packages and libraries that won't be used in production.
108+
91109
## Publishing plugins or themes
92110

93111
When publishing your plugins or themes to the marketplace, you may wish to also make them available via Composer. An example `composer.json` file for a plugin is included below:
@@ -137,6 +155,8 @@ There are many different moving parts that come together to make the Winter CMS
137155

138156
- **Vendor** packages are included via Composer in either the project's `/vendor` directory or can sometimes be found in plugin-specific `/vendor` directories. The project vendor directory takes priority over and plugin vendor directories that appear in the system.
139157

158+
> **NOTE:** Refer to the [Architecture documentation](../architecture/introduction) for more detailed information on how Winter CMS is structured.
159+
140160
## Marketplace builds
141161

142162
When you publish your plugin or theme to the marketplace, the server will conveniently pull in all the packages defined in your composer file. This makes the product ready for others to use, even if they don't use composer. Here's how it works:

0 commit comments

Comments
 (0)