10 minute tutorial - Create and deploy a Laravel application using a low-code approach
Tags: laravel, aws, php, laraboot
Published: 2021-10-13 16:38:18

---
title: 10 minute tutorial - Create and deploy a Laravel application using a low-code approach
published: true
description: 
tags: laravel, aws, php, laraboot
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/azl2h12s0c8t5765gct1.png
---
## Getting started

In this post, I want to show how quickly and easily [Laraboot](https://laraboot.io) can help you create a solid start point for your next Laravel application including **models**, CRUD **routes**, and **Jetstream** integration. Best of all, we won't have to write any code.

Once we got the application ready we will use **AWS ECR** to deploy it.


## Initialize and configure

### Prerequisites

Make sure your system has the following requirements beforehand.

-  [Docker desktop](https://www.docker.com/products/docker-desktop) 
-  [NodeJs](https://nodejs.org/es/) 
-  [AWS cli](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html)  (for deployment only)

### Install laraboot

Laraboot is installed through NPM. Check out the project [here](https://www.npmjs.com/package/@laraboot-io/cli).

```
npm i -g @laraboot-io/cli
```

### Create new project

```bash
laraboot new laraboot-demo-app --php-version=8 && cd laraboot-demo-app
```

### Buildtasks

> Build tasks are just custom  [_buildpacks_](https://buildpacks.io/docs/concepts/components/buildpack/#:~:text=A%20buildpack%20is%20a%20set,buildpack.) that create or modify a Laraboot project.

In this post, we're going to use several build tasks. If you feel adventurous, you can dive into the  [build task directory](https://laraboot.io/buildtasks/)

The ones we require are:

-  [@core/laravel-foundation-provider](https://laraboot.io/buildtask/core/laravel-foundation-provider) 
-  [@core/laravel-config](https://laraboot.io/buildtask/core/laravel-config) 
-  [@core/laravel-model](https://laraboot.io/buildtask/core/laravel-model) 
-  [@core/laravel-starterkit-buildpack](https://laraboot.io/buildtask/core/laravel-foundation-provider) 

We add them using laraboot cli like this

```bash
laraboot task add @core/laravel-foundation-provider --format=file
laraboot task add @core/laravel-config --format=file
laraboot task add @core/laravel-model --format=file
laraboot task add @core/laravel-starterkit-buildpack --format=file
```

### Configure

Let's first create our data model. For the purpose of this post let's imagine we have 2 models. Post and Comment. We'll create them using the `model` command like this:

```bash
laraboot model add Post
√ Would you like to define your model now? (y/N) · true
√ Field name? · content
√ Field type? · varchar
√ Is this field unique? (y/N) · false
√ Is this field primary key? (y/N) · false
√ Would you like to add a new field? (y/N) · false
Model Post was added
laraboot model add Comment
√ Would you like to define your model now? (y/N) · true
√ Field name? · content
√ Field type? · varchar
√ Is this field unique? (y/N) · false
√ Is this field primary key? (y/N) · false
√ Would you like to add a new field? (y/N) · false
Model Comment was added

```


Then configure **Jetstream**. Add the following piece of content to the end of your `buildpack.yml` file

```yaml
# buildpack.yml
laravel-starterkit:
  # Jetstream configuration
  jetstream:
    enabled: true
    teams: true
    stack: livewire
  # Breeze configuration
  breeze:
    enabled: false
    stack: inertia

```

## Build

Once configured, kick the build process. Mind that the build time depends on your system capabilities and whether if this is the first time you build a laraboot project. Subsequent builds are significantly faster.

```bash
laraboot build
```
If everything goes as planned you should end up with an OCI-compliant image named `laraboot-demo-app`.

## Preview

Let's see how everything looks like by running our application locally

```
laraboot run --port=9000
```

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1634142760628/T_-HlPaaQ.png)

> Awesomeness.


## Deploy to AWS

Next, we're going to use AWS as a cloud provider and AWS ECR as the service registry but you can as well deploy to the CR of your preference.

### Create an ECR repository using AWS cli

> You can skip this part if you already have an **AWS ECR** repository.

There are two ways ( maybe more ) to create an ECR repository, in this post we'll use `aws-cli`. 

```
# create an ecr repository
aws ecr create-repository \
    --repository-name laraboot-demo-app \
    --image-scanning-configuration scanOnPush=true
```

This will output something like this

```json
{
    "repository": {
        "repositoryArn": "arn:aws:ecr:us-east-1:xxxxxxxxxxxx:repository/laraboot-demo-app",
        "registryId": "xxxxxxxxxxxx",
        "repositoryName": "laraboot-demo-app",
        "repositoryUri": "xxxxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/laraboot-demo-app",
        "createdAt": "2021-10-13T10:45:53-05:00",
        "imageTagMutability": "MUTABLE",
        "imageScanningConfiguration": {
            "scanOnPush": true
        },
        "encryptionConfiguration": {
            "encryptionType": "AES256"
        }
    }
}
```

### Create an ECR repository through the AWS ECR console

You can achieve the same by signing into the AWS console and heading to the [ECR service console management](https://us-east-1.console.aws.amazon.com/ecr/repositories?region=us-east-1).

- Click on Create repository
- Fill out the blanks in the *General settings* panel
- Click on Create repository

### Deploy

The steps to deploy our image are the following

- Sign in to the AWS ECR
- Tag our image
- Deploy

```

# replace xxxxxxxxxxxx with your AWS account id
# replace region if it's not us-east-1

# sign in to the ECR
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin xxxxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com

## tag our image
docker tag laraboot-demo-app:latest xxxxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/laraboot-demo-app:latest

## push
docker push xxxxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/laraboot-demo-app:latest

```

## Conclusion

On this occasion, we use [Laraboot](https://laraboot.io/)  to set up a new Laravel application without having to write any line of code. This application has been containerized and deployed to AWS ECR in a matter of minutes.