Skip to content

Getting Started

I’ll be guiding you on how to setup the backend.

Installation

IDE

I recommend setting up your preferred IDE first for the Laravel application environment. We personally use PHPStorm for convenience, but you can choose any IDE you like.

Local Development Environment

We are using Laravel Sail to run the application locally, but you can use whichever you prefer, such as Laravel Homestead, Laravel Herd, or even XAMPP.

If you’re going to use Laravel Sail, it’s recommended to review the Laravel Sail documentation.

Setup Backend

Clone Repository

  1. Clone the repository from GitHub using your preferred terminal.

    Terminal window
    git clone https://github.com/DipluX-Solutions/capturit-laravel.git
  2. Install packages

    Terminal window
    cd capturit-laravel
    composer install
    npm install && npm run build

Setup environment variable

  1. Create a .env file and copy the contents inside the .env.example file.

    .env.example
    APP_NAME=CapturitAPI
    APP_ENV=local
    APP_KEY=
    APP_DEBUG=true
    APP_TIMEZONE=UTC
    APP_URL=
    APP_LOCALE=en
    APP_FALLBACK_LOCALE=en
    APP_FAKER_LOCALE=en_US
    APP_MAINTENANCE_DRIVER=file
    APP_MAINTENANCE_STORE=database
    BCRYPT_ROUNDS=12
    LOG_CHANNEL=stack
    LOG_STACK=single,sentry_error,sentry_critical
    LOG_DEPRECATIONS_CHANNEL=null
    LOG_LEVEL=debug
    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_DATABASE=
    DB_USERNAME=root
    DB_PASSWORD=
    SESSION_DRIVER=database
    SESSION_LIFETIME=120
    SESSION_ENCRYPT=false
    SESSION_PATH=/
    SESSION_DOMAIN=null
    BROADCAST_CONNECTION=log
    FILESYSTEM_DISK=local
    QUEUE_CONNECTION=redis
    CACHE_STORE=database
    CACHE_PREFIX=
    MEMCACHED_HOST=127.0.0.1
    REDIS_CLIENT=predis
    REDIS_HOST=127.0.0.1
    REDIS_PASSWORD=null
    REDIS_PORT=6379
    REDIS_DB=0
    REDIS_CACHE_DB=1
    ABLY_API_KEY=
    MAIL_MAILER=smtp
    MAIL_HOST=smtp.sendgrid.net
    MAIL_PORT=465
    MAIL_USERNAME=apikey
    MAIL_PASSWORD=
    MAIL_ENCRYPTION=ssl
    MAIL_FROM_ADDRESS=
    MAIL_FROM_NAME=
    AWS_ACCESS_KEY_ID=
    AWS_SECRET_ACCESS_KEY=
    AWS_DEFAULT_REGION=us-east-1
    AWS_BUCKET=
    AWS_USE_PATH_STYLE_ENDPOINT=false
    VITE_APP_NAME="${APP_NAME}"
    CLOUDFLARE_R2_TOKEN=
    CLOUDFLARE_R2_ACCESS_KEY_ID=
    CLOUDFLARE_R2_SECRET_ACCESS_KEY=
    CLOUDFLARE_R2_BUCKET=
    CLOUDFLARE_R2_BACKUP_BUCKET=
    CLOUDFLARE_R2_ENDPOINT=
    CLOUDFLARE_R2_URL=
    FIREBASE_CREDENTIALS=
    FIREBASE_PROJECT_ID=
    OCTANE_SERVER=swoole
    CIPHERSWEET_KEY=
    SENTRY_LARAVEL_DSN=null
    DISCORD_BACKUP_WEBHOOK=
  2. Update the APP_KEY

    You can generate the APP_KEY using a command, or you can use the existing APP_KEY on the server. If you want to generate a new APP_KEY without using the one on the server, simply run the command.

    Terminal window
    php artisan key:generate
  3. Update the APP_URL to match your local url

    .env
    APP_URL=http://localhost:8080
  4. Update the ABLY_API_KEY

    You can obtain the API_KEY from Ably or you can ask the owner/client to provide it so you can set it up locally.

  5. Update the MAIL_XXX

    You can setup this after creating an account from Twilio SendGrid or you can ask the owner/client to provide it so you can set it up locally.

    You can obtain the MAIL_PASSWORD after generating an API key. You should be able to create it under Settings -> API Keys

    You can obtain the MAIL_FROM_ADDRESS after setting up the Sender Identity under Settings -> Sender Authentication.

    You can decide what to put in MAIL_FROM_NAME, it’s simply the sender’s name.

  6. Update CLOUDFLARE_R2_XXX

    You should able to set this up after creating R2 API Tokens.

    1. Create/Login your CloudFlare Account
    2. Go to R2 Object Storage
    3. Create buckets for capturit-backup and capturit-storage
      • capturit-backup: For storing backup of project files and database
      • capturit-storage: For storing images such as event cover, album photos, etc…
    4. Create an API token by navigating to Manage R2 API Tokens
    5. Update the .env file with the details displayed after creating the API token. Simply add the information to the .env file.
  7. Update FIREBASE_XXX

    You should be able to set this up after the mobile developer sets up the Firebase account. Just ask them for the details.

    You’ll need to get the json file from Firebase then put it in storage -> app -> keys

    .env
    FIREBASE_CREDENTIALS=keys/capturit_firebase.json

    After getting the json file, open it and copy the value from project_id key then paste it in .env

    .env
    FIREBASE_PROJECT_ID=<project_id>
  8. Update CIPHERSWEET_KEY

    Just follow the Ciphersweet docs

  9. Update SENTRY_LARAVEL_DSN

    You don’t need to set this up in your local environment, as it is used for error monitoring in deployment projects.

  10. Update DISCORD_BACKUP_WEBHOOK

    This is related to backups and is used for sending backup events to Discord. You can use other platforms, such as Slack, to send events. Simply modify it in config -> backup.php

We are done setting up the environment variable.

Setup the database

To set up the database, ensure that MySQL is running on your machine or VM. Then, run the following command:

Terminal window
php artisan migrate --seed

This will set up the base database for Capturit.

Run the application

This depends on how you set up your local environment, but you can simply run this command:

Terminal window
php artisan serve

This should allow your Laravel application to run.