Skip to content

Commit 1b5924e

Browse files
committed
Improve app
1 parent f52e09a commit 1b5924e

File tree

16 files changed

+500
-501
lines changed

16 files changed

+500
-501
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ DEFAULT_DATE_TIMEZONE=America/Sao_Paulo
88
DATABASE_USER=xpto
99
DATABASE_PASSWORD=xpto_password
1010
DATABASE_NAME=xpto_database_name
11+
DATABASE_DRIVER=xpto_driver
12+
DATABASE_HOST=xpto_host
13+
DATABASE_SCHEMA=xpto_schema

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
FROM php:7-fpm
22

3-
RUN apt-get update && apt-get install -y curl git
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
6+
47
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@
2323
```docker
2424
docker exec -it php7 composer install
2525
```
26+
- Create Alias
27+
- Enter inside container
28+
```bash
29+
docker exec -i php7 bash
30+
```
31+
- Run script
32+
```bash
33+
./scripts/create_linux_alias.sh
34+
```
35+
- Run Migrations
36+
```bash
37+
migrate
38+
```
2639
### Receive Slack notifications with Webhooks
2740
- Configure .env application
2841
```bash

app/Base/ControllerInterface.php

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

app/Route/index.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
$route = new Router();
66

77
$route->registry('/user', \App\User\UserController::class, 'index');
8+
$route->registry('/user-create', \App\User\UserController::class, 'store');
89

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

app/User/UserController.php

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

3-
43
namespace App\User;
54

6-
75
use App\Base\ControllerInterface;
86

97
class UserController implements ControllerInterface
108
{
119
public static function index(): void
1210
{
13-
echo 'Hi! I am a index function :)';
11+
var_dump(UserModel::all()->toArray());
1412
}
1513

14+
public static function store(): void
15+
{
16+
UserModel::create([
17+
'name' => 'Xpto Name',
18+
'email' => 'xpto@email.com',
19+
'password' => password_hash('xpto#@xpto', PASSWORD_ARGON2I),
20+
]);
21+
}
1622
}

app/User/UserModel.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace App\User;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class UserModel extends Model
8+
{
9+
protected $table = 'users';
10+
11+
protected $fillable = [
12+
'name',
13+
'email',
14+
'password',
15+
];
16+
17+
protected $hidden = [
18+
'password',
19+
];
20+
}

bootstrap/index.php

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

3+
require_once __DIR__ . '/../vendor/autoload.php';
4+
35
require_once __DIR__ . '/../app/DotEnvLoader/index.php';
46

57
require_once __DIR__ . '/../app/Date/index.php';
68

9+
require_once __DIR__ . '/../database/index.php';
10+
711
require_once __DIR__ . '/../app/Route/index.php';

composer.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
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"
615
}
716
},
817
"license": "GPL-3.0-only",
@@ -26,7 +35,7 @@
2635
"vlucas/phpdotenv": "4.1.*",
2736
"guzzlehttp/guzzle": "6.5.*",
2837
"ext-json": "*",
29-
"doctrine/migrations": "^2.0"
38+
"illuminate/database": "^7.2"
3039
},
3140
"require-dev": {
3241
"phpunit/phpunit": "8.5.*"

0 commit comments

Comments
 (0)