A base project that uses Laravel 8 with Passport for use as an API backend!
View the API documentation Online!
Using Laravel Homestead in Vagrant, this entire configuration is straightforward.
If you already have an environment set up - either with Docker, natively on your local machine, or on a remote machine - then you don't need to use this entire repo, only the Laravel folder!
NOTE: This is for development environments only!
Only the Laravel folder in this directory contains the project code. Deploy that to production, not everything in this repo.
(Skip this step if you already have an environment to run Laravel in)
- Clone this repo into a desired folder (
git clone https://github.com/rslay/laravel-quickstart
) - Install Vagrant
- On Linux, use your package manager, e.g.
sudo apt install virtualbox
- On Linux, use your package manager, e.g.
- Copy
Homestead.yaml.example
toHomestead.yaml
, then in that new file... - Modify
C:\Users\<ENTER USERNAME HERE>\Desktop\laravel-quickstart\laravel
to match the path to thelaravel
folder on your machine- Change
\
to/
if you are on Linux and use the appropriate path instead (use thepwd
command while in thelaravel-quickstart
folder)
- Change
- Run
vagrant box add laravel/homestead --box-version 10.1.1
to download the laravel homestead VM - Run
vagrant up && vagrant ssh
while in thelaravel-quickstart
folder (IMPORTANT: must be done in a terminal run as Administrator on Windows)
If all went well, you should now be in a terminal in the VM running Homestead. Go to step 2 below and enter the commands.
Lets configure the local environment:
cd /home/vagrant/code
composer install
cp .env.example .env
php artisan key:generate
php artisan migrate
php artisan passport:install --force
Want to use VueJS and the frontend? Run these commands (on Windows, you have to run the terminal as Administrator):
yarn
yarn add vue-template-compiler
NOTE: Do not use
npm
! Runyarn run watch
instead,npm
currently has an issue in vagrant with shared folders.
Done! Open up the Laravel folder in your favorite IDE and get started coding!
You can open a shell to the machine with vagrant ssh
anytime.
The example routes, controllers, and models form an API with:
- Users (register/login to get an access token, view info)
- Notifications (CRUD)
- Yelp External API (external server request on behalf of user)
- To set this up, you must set the value
YELP_API_KEY
in your.env
with the value from the Yelp Manage App page, which is free and only requires you make an account.
- To set this up, you must set the value
The importable Postman JSON collection contains 12 different requests, click here to download the Postman file. It is present at the base of the laravel project folder.
You can import this to your postman by going to Import at the top left of the Postman desktop app.
Create as many test users as needed, like so:
vagrant@homestead:~$ cd code
vagrant@homestead:~/code$ php artisan tinker
>>> User::factory()->count(100)->create()
NOTE: All the user passwords are "password".
You will see all the newly created user rows.
You can try out these user accounts by logging into them, using the /api/user/login
endpoint. Refer to the previous REST API section for more details.