Skip to content

hfagerlund/quiz_app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

quiz_app

Quiz API backend using Laravel 10, Sail (docker-compose), GraphQL with Vue 3 front-end.

Release Laravel Version Composer Version Composer package: rebing/graphql-laravel Version Composer package: laravel/sail Version PHP Version PHPUnit Version MySQL Version Vite Version Vue Version Tailwind CSS Version

What's going on here?

(All copyrights for the above remain with their respective owners.)

Quick start

# clone this project
$ git clone https://github.com/hfagerlund/quiz_app.git
$ cd quiz_app
$ cp .env.example .env
# ...and create .env.testing, customize .env and /config/database.php for your db

$ composer install --ignore-platform-reqs

# start Sail (leave this running in its own terminal tab)
$ ./vendor/bin/sail up

# in a new terminal tab:
$ ./vendor/bin/sail npm install
$ ./vendor/bin/sail artisan key:generate
$ ./vendor/bin/sail artisan migrate:fresh --seed
$ ./vendor/bin/sail npm run dev
# browse to 0.0.0.0

Useful Tips

# stop Sail
$ ./vendor/bin/sail down

# check state of services
$ docker-compose ps
Differences between .env and .env.testing [+]
.env .env.testing
APP_ENV=local APP_ENV=testing
DB_CONNECTION=mysql DB_CONNECTION=test1 (corresponds to <env name="DB_CONNECTION" value="test1" /> in phpunit.xml)
DB_DATABASE=db_for_application DB_DATABASE=db_for_testing (corresponds to <env name="DB_DATABASE" value="db_for_testing"/>, <env name="APP_ENV" value="db_for_testing"/> in phpunit.xml)

Tests

# run all tests (feature, unit, database etc.)
$ ./vendor/bin/sail artisan test
# run all tests (for front-end, Vue components)
$ ./vendor/bin/sail npm run test

# run a specific test
$ ./vendor/bin/sail test --testsuite Feature --filter=DatabaseTest

# generate (feature) test
$ ./vendor/bin/sail php artisan make:test HTTPResponseTest

# generate (unit) test
$ ./vendor/bin/sail php artisan make:test MyUnitTest --unit

# output code coverage stats to terminal
$ ./vendor/bin/sail php artisan test --coverage

# install Dusk (end-to-end testing, browser automation)
$ ./vendor/bin/sail composer require --dev laravel/dusk
$ ./vendor/bin/sail php artisan dusk:install

Good to Know (miscellaneous commands)

Auto-generate code [+] models, migrations, factories, GraphQL schema
# generate model, migration
$ ./vendor/bin/sail artisan make:model -m Question

# generate model, migration, factory
$ ./vendor/bin/sail artisan make:model Question -m -f

# generate GraphQL type
$ ./vendor/bin/sail artisan make:graphql:type QuestionType
Installation [+] Laravel 10, libraries
# install Laravel 10 app (including Sail, MySQL, Redis, Selenium)
$ curl -s https://laravel.build/new-sail-application | bash

# install library for GraphQL
$ ./vendor/bin/sail composer require rebing/graphql-laravel
## publish config file (from /vendor dir to /config/graphql.php)
$ ./vendor/bin/sail php artisan vendor:publish --provider="Rebing\GraphQL\GraphQLServiceProvider"
Configuration [+] caching configuration, switching environments
# cache configuration
$ ./vendor/bin/sail php artisan config:cache --env=testing

# clear configuration cache
$ ./vendor/bin/sail php artisan config:clear
Database [+] running migrations, seeders, db schema, db client
# run migrations
$ ./vendor/bin/sail artisan migrate

# drop all tables, migrate, seed db
$ ./vendor/bin/sail artisan migrate:fresh --seed

# dump database schema (ie. 'squash' migrations into a single SQL file)
$ ./vendor/bin/sail php artisan schema:dump

# access MySQL command-line client
$ ./vendor/bin/sail mysql
Front-end Vue app [+] running Node, npm, Vite dev server
# Node, npm versions
$ ./vendor/bin/sail node -v
$ ./vendor/bin/sail npm -v

# run Vite development server (provides Hot Module Replacement for Laravel application)
$ ./vendor/bin/sail npm run dev

License

Copyright © 2023 Heini Fagerlund. License applies to all parts of quiz_app that are not externally maintained libraries, frameworks.

The Laravel framework is open-sourced software licensed under the MIT license.