Skip to content

Set up a basic app with Laravel

In this tutorial you set up a basic app and add it to the App Store. You’ll learn how to set up the app and its widgets, authenticate, communicate with the API and receive webhooks.

We use Laravel with PHP 8.1 in this example.

  1. A basic knowledge of Git. We work with the GitHub CLI.
  2. Composer, to install the dependencies. Install Composer
  3. MySQL, which we use to store tokens and logs.

Clone the basic app Git repository to your local machine:

Terminal window
git clone https://github.com/CampingCare/basic-app-laravel.git
cd basic-app-laravel/

Install the dependencies with Composer:

Terminal window
composer install

You’re only using this repository as a starting point, so remove the .git directory and start your own Git repository:

Terminal window
rm -rf .git

Copy the example .env file, where you’ll set up your MySQL database, and generate a Laravel app key:

Terminal window
cp .env.example .env
php artisan key:generate

Change the database settings in the .env file:

Terminal window
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=password

Now set up the models in your MySQL database by running a migration:

Terminal window
php artisan migrate

Start your server to check that everything works:

Terminal window
php artisan serve

The application now runs on your machine, at something like http://localhost:8000/. You’ll see the default app URL page, which looks like this:

Basic Laravel app

Go to the App Store and create a new app. Open the App Store

Add app

This app supports a default app URL and several widgets. We’ve added a reservation tab widget as an example. Learn more about App Store widgets

In this example we’ve set up a webhook receiver at http://localhost:8000/api/webhooks (for POST requests only).

This example uses the rates.update_prices webhook trigger, so you get a notification whenever a price changes. You can add multiple triggers to a single webhook.

To test the app, install it after you’ve saved it. Read more about the install process

After installing the app you’ll see this screen:

Basic Laravel app installed

That’s it: your basic app works.

The last step is to upload your application to a public host. This can be any hosting company or cloud platform you prefer, as long as it runs an up-to-date version of PHP and MySQL.