You've already forked Php-Template
Compare commits
6 Commits
v1.1.0
...
4fd8a2e3ae
| Author | SHA1 | Date | |
|---|---|---|---|
|
4fd8a2e3ae
|
|||
|
96ffb1fc95
|
|||
|
2d6d0a43f3
|
|||
|
63bdc67bb5
|
|||
|
ec2e668ddd
|
|||
|
e203975294
|
@@ -1,7 +1,7 @@
|
||||
on:
|
||||
create:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
- "v*"
|
||||
|
||||
name: 🏗️✨ Build Workflow
|
||||
|
||||
@@ -12,7 +12,6 @@ jobs:
|
||||
steps:
|
||||
- name: 🛡️ 🔒 Add Siteworx CA Certificates
|
||||
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
|
||||
update-ca-certificates
|
||||
|
||||
@@ -30,7 +29,7 @@ jobs:
|
||||
- name: 🏗️ 🔧 Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: 🐳 🔨 Build Backend Container
|
||||
- name: 🐳 🔨 Build Container
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
|
||||
@@ -14,7 +14,6 @@ jobs:
|
||||
|
||||
- name: 🛡️ 🔒 Add Siteworx CA Certificates
|
||||
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
|
||||
update-ca-certificates
|
||||
|
||||
@@ -75,7 +74,6 @@ jobs:
|
||||
steps:
|
||||
- name: 🛡️ 🔒 Add Siteworx CA Certificates
|
||||
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
|
||||
update-ca-certificates
|
||||
|
||||
@@ -113,7 +111,6 @@ jobs:
|
||||
|
||||
- name: 🛡️ 🔒 Add Siteworx CA Certificates
|
||||
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
|
||||
update-ca-certificates
|
||||
|
||||
@@ -150,7 +147,6 @@ jobs:
|
||||
steps:
|
||||
- name: 🛡️ 🔒 Add Siteworx CA Certificates
|
||||
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
|
||||
update-ca-certificates
|
||||
|
||||
@@ -187,7 +183,6 @@ jobs:
|
||||
steps:
|
||||
- name: 🛡️ 🔒 Add Siteworx CA Certificates
|
||||
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
|
||||
update-ca-certificates
|
||||
|
||||
@@ -224,7 +219,6 @@ jobs:
|
||||
steps:
|
||||
- name: 🛡️ 🔒 Add Siteworx CA Certificates
|
||||
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
|
||||
update-ca-certificates
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ COPY --from=library /app/vendor /app/vendor
|
||||
ADD src src/
|
||||
ADD server.php .
|
||||
ADD .rr.yaml .
|
||||
ADD config.php .
|
||||
|
||||
EXPOSE 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\Router;
|
||||
use Nyholm\Psr7\Factory\Psr17Factory;
|
||||
use Siteworxpro\App\Controllers\IndexController;
|
||||
use Siteworxpro\App\Facades\Config;
|
||||
use Siteworxpro\App\Facades\Logger;
|
||||
use Siteworxpro\App\Http\JsonResponseFactory;
|
||||
@@ -113,10 +114,7 @@ class Server
|
||||
*/
|
||||
protected function registerRoutes(): void
|
||||
{
|
||||
$this->router->get('/', function () {
|
||||
return JsonResponseFactory::createJsonResponse(['status_code' => 200, 'message' => 'Server is running']);
|
||||
});
|
||||
|
||||
$this->router->get('/', IndexController::class . '::get');
|
||||
$this->router->middleware(new CorsMiddleware());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user