Skip to content

Commit 33c970c

Browse files
committed
Merge branch 'feature/rollback'
2 parents 590fb49 + c734b8c commit 33c970c

21 files changed

+640
-1906
lines changed

.github/workflows/build.yml

100644100755
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ on:
44
push:
55
branches:
66
- master
7-
- feature/*
8-
- hotfix/*
97

108
jobs:
119
build:
12-
runs-on: [ubuntu-latest]
10+
runs-on: [ ubuntu-latest ]
1311
steps:
1412
- uses: actions/checkout@v1
1513

@@ -21,9 +19,5 @@ jobs:
2119

2220
- uses: php-actions/composer@master
2321

24-
- name: Config Dot Env
25-
run: |
26-
cp .env.example .env
27-
2822
- name: Run Tests
2923
run: composer test

.gitignore

100644100755
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
vendor
44

55
# FILES
6-
.env
76
.phpunit.result.cache

Dockerfile

100644100755
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
FROM php:7-fpm
2-
3-
RUN apt-get update && apt-get install -y curl git libpq-dev vim \
4-
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
5-
&& docker-php-ext-install pdo pdo_pgsql
1+
FROM php:8-fpm-buster
62

3+
RUN apt-get update && apt-get install -y curl git
74
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

README.md

100644100755
Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,53 +9,30 @@
99
| SETUP |
1010
|:------:|
1111
| Nginx |
12-
| PHP7.4 |
12+
| PHP8 |
1313
| Docker |
14-
| Postgres |
1514

1615

1716
#### Start app
1817
- Build Docker containers
19-
```bash
18+
```docker
2019
docker-compose up --build -d
2120
```
2221
2322
- Install Composer dependencies
24-
```bash
25-
docker exec -it php7 composer install
26-
```
27-
- Create Alias
28-
- Enter inside php7 container
29-
```bash
30-
docker exec -i php7 bash
31-
```
32-
- Run script
33-
```bash
34-
./scripts/create_linux_alias.sh
35-
```
36-
- Run Migrations
37-
```bash
38-
migrate
39-
```
40-
### Receive Slack notifications with Webhooks
41-
- Configure .env application
42-
```bash
43-
cp .env.example .env
44-
```
45-
- Set your Slack Api Webhook in .env
46-
```dotenv
47-
SLACK_API_WEBHOOK=your_webhook_here
23+
```docker
24+
docker exec -it php composer install
4825
```
4926
5027
### Create your own routes
5128
5229
`app/Route/index.php`
5330
5431
```php
55-
$route->registry('/user', \App\User\UserController::class, 'index');
32+
$route->registry('/greet', \App\Greet\GreetController::class, 'index');
5633
```
5734

5835
Where:
5936
- `/user` is the **route** that you want to *register*;
60-
- `\App\User\UserController::class` is the *Controller* **namespace**;
37+
- `\App\Greet\GreetController::class` is the *Controller* **namespace**;
6138
- `index` is a controller *function*

app/Base/ControllerInterface.php

100644100755
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@
77
interface ControllerInterface
88
{
99
public static function index(): void;
10-
public static function store(): void;
1110
}

app/Greet/GreetController.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace App\Greet;
4+
5+
use App\Base\ControllerInterface;
6+
7+
class GreetController implements ControllerInterface
8+
{
9+
public static function index(): void
10+
{
11+
echo 'Hi! I am a index function :)';
12+
}
13+
14+
}

app/Greet/UserModel.php

Whitespace-only changes.

app/Route/Router.php

100644100755
Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,24 @@
44
namespace App\Route;
55

66

7-
use App\Notification\Client\Guzzle\GuzzleHTTPClient;
8-
use App\Notification\NotificationTypeEnum;
9-
use App\Notification\StatusCodeEnum;
10-
use App\Notification\Slack\SlackNotification;
117
use InvalidArgumentException;
128
use ReflectionException;
139
use ReflectionMethod;
1410

15-
final class Router implements RouterInterface
11+
class Router implements RouterInterface
1612
{
13+
private const NOT_FOUND_CODE = 204;
1714
private array $routes = [];
1815

19-
public function dispatch(string $uri, array $params = []): void
16+
public function dispatch(string $requestAction, array $params = []): void
2017
{
21-
if (!key_exists($uri, $this->routes)) {
22-
throw new InvalidArgumentException("'{$uri}' is an unregistered route", StatusCodeEnum::NOT_FOUND());
18+
if (!key_exists($requestAction, $this->routes)) {
19+
throw new InvalidArgumentException("'{$requestAction}' is an unregistered route", self::NOT_FOUND_CODE);
2320
}
2421

25-
$uriContent = $this->routes[$uri];
22+
$uriContent = $this->routes[$requestAction];
2623
$reflectedControllerMethod = self::createReflectionMethod($uriContent);
24+
2725
$reflectedControllerMethod->invokeArgs(new $uriContent['namespace'], $params);
2826
}
2927

@@ -40,11 +38,7 @@ private static function createReflectionMethod(array $uriContent): ReflectionMet
4038
try {
4139
return new ReflectionMethod($uriContent['namespace'], $uriContent['method']);
4240
} catch (ReflectionException $exception) {
43-
(new SlackNotification(
44-
new GuzzleHTTPClient(),
45-
$exception->getMessage(),
46-
NotificationTypeEnum::ERROR()
47-
))->notify();
41+
print $exception->getMessage();
4842
}
4943
}
5044
}

app/Route/index.php

100644100755
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
$route = new Router();
66

7-
$route->registry('/user', \App\User\UserController::class, 'index');
8-
$route->registry('/user-create', \App\User\UserController::class, 'store');
7+
$route->registry('/greet', \App\Greet\GreetController::class, 'index');
98

10-
if ($_SERVER['REQUEST_URI']) $route->dispatch($_SERVER['REQUEST_URI']);
9+
$route->dispatch($_SERVER['REQUEST_URI']);

app/User/UserController.php

Lines changed: 0 additions & 22 deletions
This file was deleted.

app/User/UserModel.php

Lines changed: 0 additions & 20 deletions
This file was deleted.

bootstrap/index.php

100644100755
Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
11
<?php
22

3-
require_once __DIR__ . '/../vendor/autoload.php';
4-
5-
require_once __DIR__ . '/../app/DotEnvLoader/index.php';
6-
7-
require_once __DIR__ . '/../app/Date/index.php';
8-
9-
require_once __DIR__ . '/../database/index.php';
10-
113
require_once __DIR__ . '/../app/Route/index.php';

composer.json

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,6 @@
33
"config": {
44
"platform": {
55
"php": "7.4"
6-
},
7-
"github-protocols": [
8-
"https"
9-
]
10-
},
11-
"repositories": {
12-
"packagist.org": {
13-
"type": "composer",
14-
"url": "https://packagist.org"
156
}
167
},
178
"license": "GPL-3.0-only",
@@ -31,16 +22,10 @@
3122
"App\\Test\\": "tests"
3223
}
3324
},
34-
"require": {
35-
"vlucas/phpdotenv": "4.1.*",
36-
"guzzlehttp/guzzle": "6.5.*",
37-
"ext-json": "*",
38-
"illuminate/database": "^7.2"
39-
},
4025
"require-dev": {
4126
"phpunit/phpunit": "8.5.*"
4227
},
4328
"scripts": {
44-
"tests": "./vendor/bin/phpunit tests --color=always --stop-on-failure",
29+
"tests": "./vendor/bin/phpunit tests --color=always --stop-on-failure"
4530
}
4631
}

0 commit comments

Comments
 (0)