Spin up clean laravel instance with authentication and postgresql db.
First, clone the project. Copy server/.env.example
to server/.env
Run the following command:
docker-compose up -d
This will first build the image based off the project's Dockerfile
. After the image is built, it will start and the current working directory will be mounted to the app container's /var/www
.
To seed the database:
docker exec -it laravel-starter-kit-server php server/artisan db:seed
The current technologies used by the starter kit are as follows:
Type | Selected Technology | Reasoning |
---|---|---|
Transpiler | TypeScript | Static types make for code that is less buggy and easier to reason about. A basic TypeScript cheatsheet can be found here and more extensive documentation here and here |
Backend Server | Laravel | Well documented and widely supported web framework |
Data Mapping Framework | Eloquent ORM | Included with Laravel |
Database Migrations | Laravel Migrations | Provided by Laravel, so no additional dependencies |
Data Store | PostgreSQL | Open source, rock solid, industry standard |
Package Manager | npm / composer | The battle-tested choices for node/php development |
Containerization | Docker | Containers make deployment easy |
- Docker
See Getting Started section for steps.
Once spun up, you can shell into the server instances like:
docker exec -it laravel-starter-kit-server bash
Build javascript and sass:
cd server/ && npm run prod
Compiling is done via Laravel Mix.
To eek out best performance, should also run php server/artisan config:cache
and php server/artisan route:cache
, and make sure APP_DEBUG
is false and NODE_ENV=production
and APP_ENV=production
.
See the .env.example files in client and server directories.
cd server && ./vendor/bin/phpunit
Laravel has a CLI tool called Artisan. To use it:
docker exec -it laravel-starter-kit-server php server/artisan YOUR_COMMAND
Do list
to see available commands.
- Make Model and DB Migration:
php artisan make:model Todo -m
- Make Controller:
php artisan make:controller TodoController --resource --model=Todo
- Add Routes
Route::apiResource('todos', 'TodoController');
- Add Authorization Policies:
php artisan make:policy TodoPolicy --model=Todo
Register policy in AuthServiceProvider
:
Todo::class => TodoPolicy::class,
TBD
TBD
Using postgres v9.11. For local development, database runs in docker container. server/database
contains migrations, and seeds.
You can connect to the database with your favorite client at localhost:5432
!
php artisan migrate
php artisan db:seed
php artisan make:seeder TodosTableSeeder
Add it to DatabaseSeeder.php
:
$this->call(TodosTableSeeder::class);
Make sure git globally has line endings set to LF. This needs to be set before cloning the project.
- For windows:
git config --global core.autocrlf false
- For linux/mac:
git config --global core.autocrlf input
If you forget to do this in windows, you make get errors starting docker like file not found
.
Update the line endings of any files that are crlf to lf and try again.