Skip to content

Full Stack Starter Kit, using PHP/Laravel for server instead of Node.

License

Notifications You must be signed in to change notification settings

jpchip/fssk-laravel

Repository files navigation

FSSK - Laravel

Full Stack Starter Kit Laravel Playground

Full Stack Starter Kit, but using PHP/Laravel for server instead of Node.

Installing / Getting started

First, clone the project. Copy server/.env.example to server/.env and client/.env.example to client/.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 /opt/src.

This spins up a postgres instance, starts client at http://localhost:3000 and starts server at http://localhost:4000. Server calls are proxied, so http://localhost:3000/api/users will hit http://localhost:4000/api/users automagically.

To init the database:

docker exec -it server php server/artisan migrate --seed

Developing

Built With

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
View Library React Component-based views that encourage single-directional data flow
Client-side State Management MobX Simpler than Redux and requires less boilerplate
Backend Server Laravel Well documented and widely supported web framework
API Protocol REST A familiar paradigm to most developers
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
Testing Framework Jest / PHPUnit Complete testing package with an intuitive syntax
Linter tslint Keeps your TypeScript code consistent

Prerequisites

  • Docker

Setting up Dev

See Getting Started section for steps.

Once spun up, you can shell into the client or server instances like:

docker exec -it client bash
docker exec -it server bash

Building

Build client side code:

cd client/ && npm run build

Deploying / Publishing

Update your .env files to indicate a production build, like NODE_ENV=production and APP_ENV=production.

docker-compose -f docker-compose-prod.yml up

Will build the client code, spin up the server in a docker instance with http://localhost:4000/ pointing to the client's index.html and built js/css.

Next, you should generate a new application key for the production environment:

docker exec -it server php server/artisan key:generate

And run the database migrations:

docker exec -it server php server/artisan migrate

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.

Configuration

See the .env.example files in client and server directories.

Tests

Client and Server code each have their own tests, using Jest.

npm test

and

cd server && ./vendor/bin/phpunit

Artisan

Laravel has a CLI tool called Artisan. To use it:

docker exec -it server php server/artisan YOUR_COMMAND

Do list to see available commands.

How to make a new API endpoint

  • 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,

Style guide

TBD

Api Reference

TBD

Database

Using postgres v9.6. For local development, database runs in docker container. server/database contains init script, migrations, and seeds.

You can connect to the database with your favorite client at localhost:5432!

Run migrations:

php artisan migrate

Run seeds:

php artisan db:seed

Create new seeds:

php artisan make:seeder TodosTableSeeder

Add it to DatabaseSeeder.php:

$this->call(TodosTableSeeder::class);

Licensing

MIT License

About

Full Stack Starter Kit, using PHP/Laravel for server instead of Node.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •