Skip to content

Commit bc24701

Browse files
Merge pull request #20 from specialtactics/v1
Version 1 PR (Open for ongoing review until finalised)
2 parents 19d7cc9 + d843f35 commit bc24701

33 files changed

+2966
-43
lines changed

.env.example

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
###########################################################
2+
#################### Laravel Configuration ################
3+
###########################################################
4+
15
APP_NAME=Laravel
26
APP_ENV=local
37
APP_KEY=
@@ -13,24 +17,23 @@ JWT_TTL=1440
1317

1418
LOG_CHANNEL=stack
1519

16-
DB_CONNECTION=mysql
17-
DB_HOST=127.0.0.1
18-
DB_PORT=3306
19-
DB_DATABASE=homestead
20-
DB_USERNAME=homestead
20+
DB_CONNECTION=pgsql
21+
DB_HOST=your_project_postgres
22+
DB_PORT=5432
23+
DB_DATABASE=your_project_local
24+
DB_DATABASE_TEST=${DB_DATABASE}_test
25+
DB_USERNAME=laradock
2126
DB_PASSWORD=secret
2227

2328
BROADCAST_DRIVER=log
24-
CACHE_DRIVER=file
25-
SESSION_DRIVER=file
26-
SESSION_LIFETIME=120
27-
QUEUE_DRIVER=sync
29+
CACHE_DRIVER=redis
30+
QUEUE_DRIVER=redis
2831

29-
REDIS_HOST=127.0.0.1
32+
REDIS_HOST=your_project_redis
3033
REDIS_PASSWORD=null
3134
REDIS_PORT=6379
3235

33-
MAIL_DRIVER=smtp
36+
MAIL_DRIVER=log
3437
MAIL_HOST=smtp.mailtrap.io
3538
MAIL_PORT=2525
3639
MAIL_USERNAME=null
@@ -44,3 +47,46 @@ PUSHER_APP_CLUSTER=mt1
4447

4548
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
4649
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
50+
51+
52+
###########################################################
53+
################ Third Party Integrations #################
54+
###########################################################
55+
56+
# Put third-party integration env vars here
57+
58+
###########################################################
59+
###################### Docker Setup #######################
60+
###########################################################
61+
# To extend the composer process
62+
COMPOSER_PROCESS_TIMEOUT=300
63+
64+
# A fix for Windows users, to ensure the application path works
65+
COMPOSE_CONVERT_WINDOWS_PATHS=0
66+
67+
# Choose storage path on your machine. For all storage systems
68+
DATA_PATH_HOST=./storage/laradock/
69+
70+
### PHP ###########################################
71+
72+
# Select a PHP version of the Workspace and PHP-FPM containers (Does not apply to HHVM). Accepted values: 7.2 - 7.1 - 7.0 - 5.6 - 5.5
73+
PHP_VERSION=7.3
74+
75+
# Enable Xdebug
76+
PHP_XDEBUG_ENABLE=false
77+
PHP_XDEBUG_REMOTE_CONNECT_BACK=false
78+
# use this value when PHP_VERSION is above 7.2, ie. 7.3
79+
PHP_XDEBUG_VERSION=-2.7.0
80+
81+
### NGINX #################################################
82+
83+
NGINX_HOST_LOG_PATH=./storage/logs/nginx/
84+
NGINX_VIRTUAL_HOST=localhost
85+
HTTPS_METHOD=noredirect
86+
87+
### POSTGRES ##############################################
88+
89+
POSTGRES_DB=your_project_local
90+
POSTGRES_USER=laradock
91+
POSTGRES_PASSWORD=secret
92+
POSTGRES_PORT=5432

app/Policies/BasePolicy.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,22 @@
22

33
namespace App\Policies;
44

5+
use App\Models\User;
56
use Specialtactics\L5Api\Policies\RestfulModelPolicy;
67

78
class BasePolicy extends RestfulModelPolicy
89
{
10+
/**
11+
* Process 'global' authorisation rules
12+
*
13+
* @param $user
14+
* @param $ability
15+
* @return bool
16+
*/
17+
public function before(User $user, $ability)
18+
{
19+
if ($user->isAdmin()) {
20+
return true;
21+
}
22+
}
923
}

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"fideloper/proxy": "^4.0",
1616
"laravel/framework": "5.8.*",
1717
"laravel/tinker": "^1.0",
18-
"specialtactics/l5-api": "~0"
18+
"specialtactics/l5-api": "~1",
19+
"predis/predis": "^1.1"
1920
},
2021
"require-dev": {
2122
"barryvdh/laravel-ide-helper": "^2.4",
@@ -69,6 +70,7 @@
6970
"lint": "./vendor/bin/phpcs",
7071
"docs": [
7172
"@php artisan ide-helper:generate --no-interaction"
72-
]
73+
],
74+
"build": "./env/build.sh"
7375
}
7476
}

config/api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@
215215

216216
'formats' => [
217217

218-
'json' => Dingo\Api\Http\Response\Format\Json::class,
218+
'json' => Specialtactics\L5Api\Http\Response\Format\Json::class,
219219

220220
],
221221

database/factories/UserFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
return [
1818
'name' => $faker->name,
1919
'email' => $faker->unique()->safeEmail,
20-
'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
20+
'password' => 'secret',
2121
'remember_token' => str_random(10),
2222
];
2323
});

database/seeds/RoleTableSeeder.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ public function runAlways()
1010
'name' => 'admin',
1111
'description' => 'Administrator Users',
1212
]);
13+
14+
Role::firstOrCreate([
15+
'name' => 'regular',
16+
'description' => 'Regular Users',
17+
]);
1318
}
1419

1520
public function runFake()

database/seeds/UserStorySeeder.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55

66
class UserStorySeeder extends BaseSeeder
77
{
8+
/**
9+
* Credentials
10+
*/
11+
const ADMIN_CREDENTIALS = ['[email protected]', 'secret'];
12+
813
public function runFake()
914
{
1015
// Grab all roles for reference
@@ -13,10 +18,17 @@ public function runFake()
1318
// Create an admin user
1419
factory(App\Models\User::class)->create([
1520
'name' => 'Admin',
16-
'email' => '[email protected]',
21+
'email' => static::ADMIN_CREDENTIALS[0],
1722
'primary_role' => $roles->where('name', 'admin')->first()->role_id,
1823
]);
1924

25+
// Create regular user
26+
factory(App\Models\User::class)->create([
27+
'name' => 'Bob',
28+
'email' => '[email protected]',
29+
'primary_role' => $roles->where('name', 'regular')->first()->role_id,
30+
]);
31+
2032
// Get some random roles to assign to users
2133
$fakeRolesToAssignCount = 3;
2234
$fakeRolesToAssign = RoleTableSeeder::getRandomRoles($fakeRolesToAssignCount);

docker-compose.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
version: '3.7'
2+
3+
services:
4+
5+
# Workspace Container
6+
workspace:
7+
container_name: your_project_workspace
8+
build:
9+
context: ./env/docker/workspace
10+
args:
11+
- PHP_VERSION=${PHP_VERSION}
12+
- PHP_XDEBUG_ENABLE=${PHP_XDEBUG_ENABLE}
13+
- PHP_XDEBUG_VERSION=${PHP_XDEBUG_VERSION}
14+
- PHP_XDEBUG_REMOTE_CONNECT_BACK=${PHP_XDEBUG_REMOTE_CONNECT_BACK}
15+
- COMPOSER_PROCESS_TIMEOUT=${COMPOSER_PROCESS_TIMEOUT}
16+
volumes:
17+
- ./:/var/www:cached
18+
- ~/.ssh:/home/laradock/.ssh
19+
- ~/.gitconfig:/home/laradock/.gitconfig
20+
- ~/.config/composer:/home/laradock/.config/composer
21+
- ~/.aws:/home/laradock/.aws
22+
tty: true
23+
networks:
24+
- your_project_network
25+
26+
# PHP-FPM
27+
php-fpm:
28+
container_name: your_project_php_fpm
29+
build:
30+
context: ./env/docker/php-fpm
31+
args:
32+
- PHP_VERSION=${PHP_VERSION}
33+
- PHP_XDEBUG_ENABLE=${PHP_XDEBUG_ENABLE}
34+
- PHP_XDEBUG_VERSION=${PHP_XDEBUG_VERSION}
35+
- PHP_XDEBUG_REMOTE_CONNECT_BACK=${PHP_XDEBUG_REMOTE_CONNECT_BACK}
36+
volumes:
37+
- ./:/var/www:cached
38+
depends_on:
39+
- workspace
40+
networks:
41+
- your_project_network
42+
43+
# NGINX
44+
nginx:
45+
container_name: your_project_nginx
46+
build:
47+
context: ./env/docker/nginx
48+
volumes:
49+
- ./:/var/www:cached
50+
- ${NGINX_HOST_LOG_PATH}:/var/log/nginx
51+
depends_on:
52+
- php-fpm
53+
- postgres
54+
environment:
55+
- HTTPS_METHOD=${HTTPS_METHOD}
56+
ports:
57+
- 80:80
58+
networks:
59+
- your_project_network
60+
61+
# PostgreSQL
62+
postgres:
63+
container_name: your_project_postgres
64+
build:
65+
context: ./env/docker/postgres
66+
volumes:
67+
- ${DATA_PATH_HOST}postgres:/var/lib/postgresql/data
68+
environment:
69+
- POSTGRES_DB=${POSTGRES_DB}
70+
- POSTGRES_USER=${POSTGRES_USER}
71+
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
72+
networks:
73+
- your_project_network
74+
75+
# Redis
76+
redis:
77+
container_name: your_project_redis
78+
image: "redis"
79+
hostname: your_project_redis
80+
networks:
81+
- your_project_network
82+
83+
# Volumes configuration
84+
volumes:
85+
postgres:
86+
driver: "local"
87+
88+
# Network configuration
89+
networks:
90+
your_project_network:
91+
name: your_project_network

env/build.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
composer install
4+
composer dump-autoload --optimize
5+
php artisan ide-helper:generate
6+
php artisan ide-helper:meta

env/docker/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.idea
2+
/logs
3+
/data
4+
.env
5+
/.project
6+
.docker-sync
7+
/jenkins/jenkins_home

0 commit comments

Comments
 (0)