This document describes the process for running this application on your local computer.
Getting Started Running the project Database
Stack Underflow is powered by Laravel, Vue.js 2 and Inertia. You should read their respective documentation before proceeding to make changes to this project.
- Docker
Before running the project, we need to install our dependencies first.
This project uses Laravel Sail, a command-line interface for interacting with Laravel's Docker development environment.
To start using it, we need to install our composer dependencies (including Sail) first:
docker run --rm \
-u "$(id -u):$(id -g)" \
-v $(pwd):/var/www/html \
-w /var/www/html \
laravelsail/php81-composer:latest \
composer install --ignore-platform-reqs
You may wish to setup a Bash alias for sail:
alias sail='[ -f sail ] && bash sail || bash vendor/bin/sail'
or by manually adding the following to your ~/.bash_aliases
:
alias sail='bash vendor/bin/sail'
This makes it so you can run sail commands by typing sail
instead of vendor/bin/sail
.
Now we need to install our front-end dependencies:
npm install
With our dependencies installed, we just need to create a .env file to store our environment variables before we can run the project.
We have an example file, so you can copy that into your own:
cp .env.example .env
We can now initialize sail with the following command:
sail up -d
Finally, don't forget to generate a new app key:
sail artisan key:generate
We use Algolia for search. After setting up an application through the Algolia website, get the app credentials and set them on the .env file:
ALGOLIA_APP_ID=
ALGOLIA_SECRET=
When you save or update a model, the data is synchronized automatically (unless you're using mass assignment methods).
However, if you imported a database or already had existing data before setting up Algolia, you may wish to import the records manually. You can easily do so with:
sail artisan scout:import
To initialize our database, we need to run our migrations. You can do so with:
sail artisan migrate
You may also wish to seed the development database in order to have some dummy test data. You can do so with:
sail artisan db:seed
The only thing left to access the website is to add the record 127.0.0.1 stackunderflow.test
to your hosts file.