Composer create-project roots/bedrock vs composer install

Hi,

As part of the Bedrock install I needed to run composer create-project roots/bedrock which generated the following output:

Installing roots/bedrock (1.8.8)
  - Installing roots/bedrock (1.8.8): Downloading (100%)
Created project in C:\Users\Justin\Documents\bedrock
> php -r "copy('.env.example', '.env');"
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Package operations: 8 installs, 0 updates, 0 removals
  - Installing johnpbloch/wordpress-core-installer (1.0.0.2): Downloading (100%)
  - Installing composer/installers (v1.5.0): Downloading (100%)
  - Installing johnpbloch/wordpress-core (4.9.4): Downloading (100%)
  - Installing johnpbloch/wordpress (4.9.4): Downloading (100%)
  - Installing oscarotero/env (v1.1.0): Downloading (100%)
  - Installing roots/wp-password-bcrypt (1.0.0): Downloading (100%)
  - Installing vlucas/phpdotenv (v2.4.0): Downloading (100%)
  - Installing squizlabs/php_codesniffer (3.2.2): Downloading (100%)
Generating autoload files

Then I created the recommended folder structure as instructed by https://github.com/roots/trellis.

After doing this successfully I pulled in Wordpress core using composer install which generated the foloowing output:

    PS C:\Users\Justin\Documents\Sites\test.com\site> composer install                                                                               
    Loading composer repositories with package information                                                                                           
    Installing dependencies (including require-dev) from lock file                                                                                   
    Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update
    hem.                                                                                                                                             
    Package operations: 8 installs, 0 updates, 0 removals                                                                                            
      - Installing johnpbloch/wordpress-core-installer (1.0.0.2): Loading from cache                                                                 
      - Installing composer/installers (v1.5.0): Loading from cache                                                                                  
      - Installing johnpbloch/wordpress-core (4.9.4): Loading from cache                                                                             
      - Installing johnpbloch/wordpress (4.9.4): Loading from cache                                                                                  
      - Installing oscarotero/env (v1.1.0): Loading from cache                                                                                       
      - Installing roots/wp-password-bcrypt (1.0.0): Loading from cache                                                                              
      - Installing vlucas/phpdotenv (v2.4.0): Loading from cache                                                                                     
      - Installing squizlabs/php_codesniffer (3.2.2): Loading from cache                                                                             
    Generating autoload files                                                                                                                        

The question is, what is the difference between running composer create-project roots/bedrock and composer install?

It seems that both pull in wordpress core files but composer create-project roots/bedrock installs roots bedrock and pulls in a “.env” file and composer install does not install roots/bedrock and pulls in additional files.

Which method should I use to set up the initial recommended folder structure?

Thanks

Are you using Trellis for local development? Because if you are, when you run vagrant up it installs Bedrock including creation of .env based on the variables you set in Trellis’ group_vars. Following the Trellis docs verbatim will get you what you want:

If you are using Bedrock on its own, using composer create-project is what the docs recommend:

Also, like you described, running composer create-project will create an .env file from the example one:

In the case of installing Bedrock without Trellis, you’ll need to update the .env with the correct variables for the environment.

1 Like

Hi,

I am using Trellis for local development.

So I only use composer create-project if I am using bedrock on its own?

Correct. If you follow the Trellis docs verbatim, you shouldn’t need to touch Bedrock’s .env at all. Trellis manages it.

Btw I am using Windows. So when creating the recommended folder structure,

I don’t need to do any composer commands until push to Trellis using vagrant up?

Thanks

Correct. You don’t need to use composer to install Bedrock when using Trellis — even on Windows. I’ll jump over to your other topic and do my best to address it as well.

thanks knowler, when I clone the trellis and bedrock repos to set up the folder structure the wp/ folder is not there.

Does this matter? if yes, what is the recommended way to pull it in?

It is a composer dependency so when Trellis installs Bedrock, it gets installed as well. You can be sure that docs are not lacking. Following the Trellis docs on macOS or Windows does work.

thanks knowler, when I clone the trellis and bedrock repos to set up the folder structure the wp/ folder is not there.

Does this matter? if yes, what is the recommended way to pull it in?

So the wp/ folder missing doesn’t matter, I can continue development and when I want to push to staging using Trellis, vagrant up pulls in the wp/ folder, so i need not be concerned?

No, vagrant up is only used for the initial local dev server setup and for spinning up existing Trellis boxes. Trellis uses Vagrant locally to setup a virtual machine and then, on the VM, Ansible provisions it and sets up application — which includes installings the composer dependencies for Bedrock (i.e. WordPress). For remote environments (staging/productions) it’s a bit different, but there is a guide in the docs:

And since you are on Windows — which Ansible does not support — you will need to follow the Windows docs for this as well. It involves running the Ansible commands from the VM (Ubuntu).

Also, I would really recommend you read @swalkinshaw’s series of blog posts regarding some of the philosophy behind the Roots ecosystem. I’m sure it will be enlightening.

Send me a DM if you would like further clarification. I would be glad to help.

Hi knowler,

Thanks for the detailed response and resources.