Skip to content

Commit

Permalink
Update installation instructions for Composer and NPM/Yarn
Browse files Browse the repository at this point in the history
  • Loading branch information
jaydrogers committed Jan 3, 2024
1 parent fd39f16 commit d0d8d12
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 41 deletions.
51 changes: 34 additions & 17 deletions docs/content/docs/2.installation/4.install-composer.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,53 @@ layout: docs
Installing `spin` at the project level is a great way to deploy `spin` without much configuration from the user's end. [View `spin` on Packagist →](https://packagist.org/packages/serversideup/spin)

## Add `spin` to your project with Composer
<alert type="warning">

This example is using `PHP 8.1`. Be sure to change the image name to match your version of PHP that you're using for your project. [See available versions →](https://github.com/serversideup/docker-php/#available-docker-images)

</alert>

We can use Docker to run `composer` and install it on your project. **Run this command from the parent folder of your project.**

::code-panel
---
label: Install `spin` with Composer
---
```bash
docker run --rm -e "LOG_LEVEL=off" -v $(pwd):/var/www/html serversideup/php:8.1-fpm composer require serversideup/spin --dev
```

#### If you already have composer installed on your machine:
We're essentially just installing it like this:
```bash
composer require serversideup/spin --dev
docker run --rm -it -v $(pwd):/app composer require serversideup/spin --dev
```
::

## Spin is installed 🥳
You should now be able to access `spin` by running:

::code-panel
---
label: Confirm Spin is working
---
```bash
./vendor/bin/spin up
bash vendor/bin/spin version
```
::

### Bonus Tip: Use an alias
Rather than typing `./vendor/bin/spin` every time, you can add a "smart alias", which will check to see if it exists in your `node_modules`, if not, it loads it from the `vendor` folder.
Rather than typing `vendor/bin/spin` every time, you can add a "smart alias", which will check to see if it exists in your `node_modules`, if not, it loads it from the `vendor` folder.

You can add the following below to your `~/.bash_profile` or your `~/.zshrc`.

Just add this in your `~/.bash_profile` or your `~/.zshrc`:
::code-panel
---
label: Add to your shell profile (recommended)
---
```bash
alias spin='[ -f node_modules/.bin/spin ] && bash node_modules/.bin/spin || bash vendor/bin/spin'
```
::

You'll now be able to access `spin` from your project root directory.

You'll now be able to access `spin` from your project root directory.
## Initialize Your Project
Once Spin is installed, you can follow the initialization wizard for your project by running `spin init`.

::code-panel
---
label: Initialize Spin with your project
---
```bash
spin init
```
::
64 changes: 40 additions & 24 deletions docs/content/docs/2.installation/5.install-npm-yarn.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,64 @@ Installing `spin` at the project level is a great way to deploy `spin` without m
## Add `spin` to your project with Yarn/NPM
We can use Docker to run install `spin` on your project. **Run this command from the parent folder of your project.**

<alert type="warning">

::note
The examples below are using `node:latest`. Be sure to change the image name to match your version of Node that you're using for your project. [See available versions →](https://hub.docker.com/_/node/)
::

</alert>

#### Yarn (with Docker)
::code-panel
---
label: Install `spin` with Yarn + Docker
---
```bash
docker run --rm -v $(pwd):/usr/app/src -w /usr/app/src/ node yarn add @serversideup/spin --dev
```
#### NPM (with Docker)
```bash
docker run --rm -v $(pwd):/usr/app/src -w /usr/app/src/ node npm install @serversideup/spin --dev
```
::


#### If you already have `yarn` or `npm` installed on your machine
We're essentially just installing it like this:

**Yarn:**
```bash
yarn add @serversideup/spin --dev
```
**NPM:**
::code-panel
---
label: Install `spin` with NPM + Docker
---
```bash
npm install @serversideup/spin --dev
docker run --rm -v $(pwd):/usr/app/src -w /usr/app/src/ node npm install @serversideup/spin --dev
```


::

## Spin is installed 🥳
You should now be able to access `spin` by running:
You should now be able to access `spin` by running the command below.

::code-panel
---
label: Run `spin` from your project
---
```bash
./node_modules/.bin/spin up
```
::

### Bonus Tip: Use an alias
Rather than typing `./node_modules/.bin/spin` every time, you can add a "smart alias", which will check to see if it exists in your `node_modules`, if not, it loads it from the `vendor` folder.

Just add this in your `~/.bash_profile` or your `~/.zshrc`:
You can add the following below to your `~/.bash_profile` or your `~/.zshrc`.

::code-panel
---
label: Add to your shell profile (recommended)
---
```bash
alias spin='[ -f node_modules/.bin/spin ] && bash node_modules/.bin/spin || bash vendor/bin/spin'
```
::

You'll now be able to access `spin` from your project root directory.

You'll now be able to access `spin` from your project root directory.
## Initialize Your Project
Once Spin is installed, you can follow the initialization wizard for your project by running `spin init`.

::code-panel
---
label: Initialize Spin with your project
---
```bash
spin init
```
::

0 comments on commit d0d8d12

Please sign in to comment.