You've already forked Php-Template
Compare commits
37 Commits
v0.0.2
...
96ffb1fc95
| Author | SHA1 | Date | |
|---|---|---|---|
|
96ffb1fc95
|
|||
|
63bdc67bb5
|
|||
|
ec2e668ddd
|
|||
|
e203975294
|
|||
|
b1e5470a07
|
|||
|
5f9ee939d6
|
|||
|
e9a3a5885f
|
|||
|
f12559d2c3
|
|||
|
b466495ae1
|
|||
|
4eb21ace55
|
|||
|
a3e54ce989
|
|||
|
403cb4c12e
|
|||
|
9f048e408c
|
|||
|
be570a3173
|
|||
|
6353a4f19e
|
|||
|
59bcf4d2a7
|
|||
|
89bc3e75ec
|
|||
|
fb04e9c390
|
|||
|
77d66abbe0
|
|||
|
52aa7abc2d
|
|||
|
b6256a7e1d
|
|||
|
59fa57d643
|
|||
|
199921fb83
|
|||
|
aaf772dc6d
|
|||
|
89fd169067
|
|||
|
a01a0c590b
|
|||
|
dfccf9ca4f
|
|||
|
011a1e77c0
|
|||
|
7c7b538616
|
|||
|
71fa18bc17
|
|||
|
7308f33de4
|
|||
|
d0d18fd603
|
|||
|
f57406f981
|
|||
|
e46bf5a6ec
|
|||
|
02acc9afbe
|
|||
|
cdb2b28cb7
|
|||
|
118e83414d
|
@@ -1,7 +1,7 @@
|
|||||||
on:
|
on:
|
||||||
create:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- '*'
|
- "v*"
|
||||||
|
|
||||||
name: 🏗️✨ Build Workflow
|
name: 🏗️✨ Build Workflow
|
||||||
|
|
||||||
@@ -12,7 +12,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: 🛡️ 🔒 Add Siteworx CA Certificates
|
- name: 🛡️ 🔒 Add Siteworx CA Certificates
|
||||||
run: |
|
run: |
|
||||||
apt update && apt install -yq ca-certificates curl
|
|
||||||
curl -Ls https://siteworxpro.com/hosted/Siteworx+Root+CA.pem -o /usr/local/share/ca-certificates/sw.crt
|
curl -Ls https://siteworxpro.com/hosted/Siteworx+Root+CA.pem -o /usr/local/share/ca-certificates/sw.crt
|
||||||
update-ca-certificates
|
update-ca-certificates
|
||||||
|
|
||||||
@@ -30,7 +29,7 @@ jobs:
|
|||||||
- name: 🏗️ 🔧 Set up Docker Buildx
|
- name: 🏗️ 🔧 Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: 🐳🔨 Build Backend Container
|
- name: 🐳 🔨 Build Container
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
|
|||||||
@@ -7,14 +7,13 @@ name: 🧪✨ Tests Workflow
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
LicenseCheck:
|
DatabaseMigrations:
|
||||||
name: License Check
|
name: 🧪 ✨ Database Migrations
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: 🛡️ 🔒 Add Siteworx CA Certificates
|
- name: 🛡️ 🔒 Add Siteworx CA Certificates
|
||||||
run: |
|
run: |
|
||||||
apt update && apt install -yq ca-certificates curl
|
|
||||||
curl -Ls https://siteworxpro.com/hosted/Siteworx+Root+CA.pem -o /usr/local/share/ca-certificates/sw.crt
|
curl -Ls https://siteworxpro.com/hosted/Siteworx+Root+CA.pem -o /usr/local/share/ca-certificates/sw.crt
|
||||||
update-ca-certificates
|
update-ca-certificates
|
||||||
|
|
||||||
@@ -29,7 +28,67 @@ jobs:
|
|||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: Install Composer Libraries
|
- name: 🏎️ 🏁 Start Support Containers
|
||||||
|
run: |
|
||||||
|
echo "Starting Support Containers"
|
||||||
|
docker run --rm \
|
||||||
|
--network "${{ env.JOB_CONTAINER_NAME }}-${{ gitea.job }}-network" \
|
||||||
|
--name ${{ gitea.job }}-${{ gitea.run_id }}-postgres \
|
||||||
|
-e POSTGRES_USER=postgres \
|
||||||
|
-e POSTGRES_PASSWORD=postgres \
|
||||||
|
-e POSTGRES_DB=postgres \
|
||||||
|
-p 5432 \
|
||||||
|
-d postgres:17
|
||||||
|
|
||||||
|
echo "Waiting for Postgres to start"
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
- name: 💽 ⬆️ Run Migrations
|
||||||
|
run: |
|
||||||
|
docker run \
|
||||||
|
--name ${{ gitea.run_id }}-migrate \
|
||||||
|
--rm \
|
||||||
|
--volumes-from ${{ env.JOB_CONTAINER_NAME }} \
|
||||||
|
--network "${{ env.JOB_CONTAINER_NAME }}-${{ gitea.job }}-network" \
|
||||||
|
-w ${{ github.workspace }} \
|
||||||
|
siteworxpro/migrate:v4.18.3 -database "postgres://postgres:postgres@${{ gitea.job }}-${{ gitea.run_id }}-postgres:5432/postgres?sslmode=disable" -path db/migrations up
|
||||||
|
|
||||||
|
- name: 💽 ⬇️ Rollback Migrations
|
||||||
|
run: |
|
||||||
|
docker run \
|
||||||
|
--name ${{ gitea.run_id }}-migrate \
|
||||||
|
--rm \
|
||||||
|
--volumes-from ${{ env.JOB_CONTAINER_NAME }} \
|
||||||
|
--network "${{ env.JOB_CONTAINER_NAME }}-${{ gitea.job }}-network" \
|
||||||
|
-w ${{ github.workspace }} \
|
||||||
|
siteworxpro/migrate:v4.18.3 -database "postgres://postgres:postgres@${{ gitea.job }}-${{ gitea.run_id }}-postgres:5432/postgres?sslmode=disable" -path db/migrations down --all
|
||||||
|
|
||||||
|
- name: 🧨 💥 Tear Down Support Containers
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker stop ${{ gitea.job }}-${{ gitea.run_id }}-postgres
|
||||||
|
|
||||||
|
LibraryAudit:
|
||||||
|
name: 🛡️ 🔒 Library Audit
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: 🛡️ 🔒 Add Siteworx CA Certificates
|
||||||
|
run: |
|
||||||
|
curl -Ls https://siteworxpro.com/hosted/Siteworx+Root+CA.pem -o /usr/local/share/ca-certificates/sw.crt
|
||||||
|
update-ca-certificates
|
||||||
|
|
||||||
|
- name: 📖 🔍 Checkout Repository Code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: 🔑 🔐 Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: 📖 ✨ Install Composer Libraries
|
||||||
run: |
|
run: |
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
--volumes-from ${{ env.JOB_CONTAINER_NAME }} \
|
--volumes-from ${{ env.JOB_CONTAINER_NAME }} \
|
||||||
@@ -37,7 +96,44 @@ jobs:
|
|||||||
siteworxpro/composer \
|
siteworxpro/composer \
|
||||||
install --ignore-platform-reqs --no-interaction --prefer-dist --optimize-autoloader
|
install --ignore-platform-reqs --no-interaction --prefer-dist --optimize-autoloader
|
||||||
|
|
||||||
- name: Run License Check
|
- name: Run Library Audit
|
||||||
|
run: |
|
||||||
|
docker run --rm \
|
||||||
|
--volumes-from ${{ env.JOB_CONTAINER_NAME }} \
|
||||||
|
-w ${{ github.workspace }} \
|
||||||
|
siteworxpro/composer \
|
||||||
|
audit
|
||||||
|
|
||||||
|
LicenseCheck:
|
||||||
|
name: 🛡️ 🔒 License Check
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: 🛡️ 🔒 Add Siteworx CA Certificates
|
||||||
|
run: |
|
||||||
|
curl -Ls https://siteworxpro.com/hosted/Siteworx+Root+CA.pem -o /usr/local/share/ca-certificates/sw.crt
|
||||||
|
update-ca-certificates
|
||||||
|
|
||||||
|
- name: 📖 🔍 Checkout Repository Code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: 🔑 🔐 Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: 📖 ✨ Install Composer Libraries
|
||||||
|
run: |
|
||||||
|
docker run --rm \
|
||||||
|
--volumes-from ${{ env.JOB_CONTAINER_NAME }} \
|
||||||
|
-w ${{ github.workspace }} \
|
||||||
|
siteworxpro/composer \
|
||||||
|
install --ignore-platform-reqs --no-interaction --prefer-dist --optimize-autoloader
|
||||||
|
|
||||||
|
- name: 🎟️ 🔬 Run License Check
|
||||||
run: |
|
run: |
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
--volumes-from ${{ env.JOB_CONTAINER_NAME }} \
|
--volumes-from ${{ env.JOB_CONTAINER_NAME }} \
|
||||||
@@ -46,12 +142,11 @@ jobs:
|
|||||||
run tests:license
|
run tests:license
|
||||||
|
|
||||||
CodeLint:
|
CodeLint:
|
||||||
name: Code Lint
|
name: 📝 ✨ Code Lint
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: 🛡️ 🔒 Add Siteworx CA Certificates
|
- name: 🛡️ 🔒 Add Siteworx CA Certificates
|
||||||
run: |
|
run: |
|
||||||
apt update && apt install -yq ca-certificates curl
|
|
||||||
curl -Ls https://siteworxpro.com/hosted/Siteworx+Root+CA.pem -o /usr/local/share/ca-certificates/sw.crt
|
curl -Ls https://siteworxpro.com/hosted/Siteworx+Root+CA.pem -o /usr/local/share/ca-certificates/sw.crt
|
||||||
update-ca-certificates
|
update-ca-certificates
|
||||||
|
|
||||||
@@ -66,7 +161,7 @@ jobs:
|
|||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: Install Composer Libraries
|
- name: 📖 ✨ Install Composer Libraries
|
||||||
run: |
|
run: |
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
--volumes-from ${{ env.JOB_CONTAINER_NAME }} \
|
--volumes-from ${{ env.JOB_CONTAINER_NAME }} \
|
||||||
@@ -83,12 +178,11 @@ jobs:
|
|||||||
run tests:lint
|
run tests:lint
|
||||||
|
|
||||||
CodeSniffer:
|
CodeSniffer:
|
||||||
name: Code Sniffer
|
name: 🐙 🔍 Code Sniffer
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: 🛡️ 🔒 Add Siteworx CA Certificates
|
- name: 🛡️ 🔒 Add Siteworx CA Certificates
|
||||||
run: |
|
run: |
|
||||||
apt update && apt install -yq ca-certificates curl
|
|
||||||
curl -Ls https://siteworxpro.com/hosted/Siteworx+Root+CA.pem -o /usr/local/share/ca-certificates/sw.crt
|
curl -Ls https://siteworxpro.com/hosted/Siteworx+Root+CA.pem -o /usr/local/share/ca-certificates/sw.crt
|
||||||
update-ca-certificates
|
update-ca-certificates
|
||||||
|
|
||||||
@@ -120,12 +214,11 @@ jobs:
|
|||||||
run tests:phpstan
|
run tests:phpstan
|
||||||
|
|
||||||
UnitTests:
|
UnitTests:
|
||||||
name: Unit Tests
|
name: 🧪 ✅ Unit Tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: 🛡️ 🔒 Add Siteworx CA Certificates
|
- name: 🛡️ 🔒 Add Siteworx CA Certificates
|
||||||
run: |
|
run: |
|
||||||
apt update && apt install -yq ca-certificates curl
|
|
||||||
curl -Ls https://siteworxpro.com/hosted/Siteworx+Root+CA.pem -o /usr/local/share/ca-certificates/sw.crt
|
curl -Ls https://siteworxpro.com/hosted/Siteworx+Root+CA.pem -o /usr/local/share/ca-certificates/sw.crt
|
||||||
update-ca-certificates
|
update-ca-certificates
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ COPY --from=library /app/vendor /app/vendor
|
|||||||
ADD src src/
|
ADD src src/
|
||||||
ADD server.php .
|
ADD server.php .
|
||||||
ADD .rr.yaml .
|
ADD .rr.yaml .
|
||||||
|
ADD config.php .
|
||||||
|
|
||||||
EXPOSE 9501
|
EXPOSE 9501
|
||||||
|
|
||||||
|
|||||||
17
README.md
17
README.md
@@ -10,13 +10,28 @@
|
|||||||
- Docker
|
- Docker
|
||||||
- Docker Compose
|
- Docker Compose
|
||||||
|
|
||||||
|
### migrations
|
||||||
|
|
||||||
|
create a new migration
|
||||||
|
```shell
|
||||||
|
docker run --rm -v $(PWD):/app siteworxpro/migrate:v4.18.3 create -ext sql -dir /app/db/migrations -seq create_users_table
|
||||||
|
```
|
||||||
|
|
||||||
|
```text
|
||||||
|
postgres://siteworxpro:password@localhost:5432/siteworxpro?sslmode=disable
|
||||||
|
```
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docker run --rm -v $(PWD):/app siteworxpro/migrate:v4.18.3 -database "postgres://siteworxpro:password@localhost:5432/siteworxpro?sslmode=disable" -path /app/db/migrations up
|
||||||
|
```
|
||||||
|
|
||||||
### Starting the Runtime
|
### Starting the Runtime
|
||||||
```shell
|
```shell
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
```
|
```
|
||||||
### Start the server
|
### Start the server
|
||||||
```shell
|
```shell
|
||||||
docker exec -it template-runtime-1 rr serve
|
docker exec -it template-dev-runtime-1 rr serve
|
||||||
```
|
```
|
||||||
|
|
||||||
You can access the api at `http://localhost:9501/`
|
You can access the api at `http://localhost:9501/`
|
||||||
|
|||||||
46
src/Controllers/Controller.php
Normal file
46
src/Controllers/Controller.php
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Siteworxpro\App\Controllers;
|
||||||
|
|
||||||
|
use League\Route\Http\Exception\NotFoundException;
|
||||||
|
use Nyholm\Psr7\ServerRequest;
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
|
||||||
|
abstract class Controller implements ControllerInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param ServerRequest $request
|
||||||
|
* @return ResponseInterface
|
||||||
|
* @throws NotFoundException
|
||||||
|
*/
|
||||||
|
public function get(ServerRequest $request): ResponseInterface
|
||||||
|
{
|
||||||
|
throw new NotFoundException("not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws NotFoundException
|
||||||
|
*/
|
||||||
|
public function post(ServerRequest $request): ResponseInterface
|
||||||
|
{
|
||||||
|
throw new NotFoundException("not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws NotFoundException
|
||||||
|
*/
|
||||||
|
public function delete(ServerRequest $request): ResponseInterface
|
||||||
|
{
|
||||||
|
throw new NotFoundException("not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws NotFoundException
|
||||||
|
*/
|
||||||
|
public function patch(ServerRequest $request): ResponseInterface
|
||||||
|
{
|
||||||
|
throw new NotFoundException("not found");
|
||||||
|
}
|
||||||
|
}
|
||||||
43
src/Controllers/ControllerInterface.php
Normal file
43
src/Controllers/ControllerInterface.php
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Siteworxpro\App\Controllers;
|
||||||
|
|
||||||
|
use Nyholm\Psr7\ServerRequest;
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
|
||||||
|
interface ControllerInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle the request and return a response.
|
||||||
|
*
|
||||||
|
* @param ServerRequest $request The request data.
|
||||||
|
* @return ResponseInterface The response data.
|
||||||
|
*/
|
||||||
|
public function get(ServerRequest $request): ResponseInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the request and return a response.
|
||||||
|
*
|
||||||
|
* @param ServerRequest $request The request data.
|
||||||
|
* @return ResponseInterface The response data.
|
||||||
|
*/
|
||||||
|
public function post(ServerRequest $request): ResponseInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the request and return a response.
|
||||||
|
*
|
||||||
|
* @param ServerRequest $request The request data.
|
||||||
|
* @return ResponseInterface The response data.
|
||||||
|
*/
|
||||||
|
public function delete(ServerRequest $request): ResponseInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the request and return a response.
|
||||||
|
*
|
||||||
|
* @param ServerRequest $request The request data.
|
||||||
|
* @return ResponseInterface The response data.
|
||||||
|
*/
|
||||||
|
public function patch(ServerRequest $request): ResponseInterface;
|
||||||
|
}
|
||||||
27
src/Controllers/IndexController.php
Normal file
27
src/Controllers/IndexController.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Siteworxpro\App\Controllers;
|
||||||
|
|
||||||
|
use Nyholm\Psr7\ServerRequest;
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
use Siteworxpro\App\Http\JsonResponseFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class IndexController
|
||||||
|
*
|
||||||
|
* This class handles the index route of the application.
|
||||||
|
*/
|
||||||
|
class IndexController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handles the GET request for the index route.
|
||||||
|
*
|
||||||
|
* @throws \JsonException
|
||||||
|
*/
|
||||||
|
public function get(ServerRequest $request): ResponseInterface
|
||||||
|
{
|
||||||
|
return JsonResponseFactory::createJsonResponse(['status_code' => 200, 'message' => 'Server is running']);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ use League\Route\Http\Exception\MethodNotAllowedException;
|
|||||||
use League\Route\Http\Exception\NotFoundException;
|
use League\Route\Http\Exception\NotFoundException;
|
||||||
use League\Route\Router;
|
use League\Route\Router;
|
||||||
use Nyholm\Psr7\Factory\Psr17Factory;
|
use Nyholm\Psr7\Factory\Psr17Factory;
|
||||||
|
use Siteworxpro\App\Controllers\IndexController;
|
||||||
use Siteworxpro\App\Facades\Config;
|
use Siteworxpro\App\Facades\Config;
|
||||||
use Siteworxpro\App\Facades\Logger;
|
use Siteworxpro\App\Facades\Logger;
|
||||||
use Siteworxpro\App\Http\JsonResponseFactory;
|
use Siteworxpro\App\Http\JsonResponseFactory;
|
||||||
@@ -113,10 +114,7 @@ class Server
|
|||||||
*/
|
*/
|
||||||
protected function registerRoutes(): void
|
protected function registerRoutes(): void
|
||||||
{
|
{
|
||||||
$this->router->get('/', function () {
|
$this->router->get('/', IndexController::class . '::get');
|
||||||
return JsonResponseFactory::createJsonResponse(['status_code' => 200, 'message' => 'Server is running']);
|
|
||||||
});
|
|
||||||
|
|
||||||
$this->router->middleware(new CorsMiddleware());
|
$this->router->middleware(new CorsMiddleware());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user