Skip to content

Commit 20b40c6

Browse files
utilizando projeto esqueleto do slim para estudo
1 parent 7daa595 commit 20b40c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3297
-124
lines changed

.coveralls.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
json_path: coveralls-upload.json

.gitignore

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ vendor/*
44
/vendor/*
55
.idea/*
66
/.idea/
7-
8-
9-
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
10-
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
11-
# composer.lock
7+
/coverage/
8+
/logs/*
9+
!/logs/README.md

.htaccess

-6
This file was deleted.

.travis.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
language: php
2+
3+
dist: trusty
4+
5+
matrix:
6+
include:
7+
- php: 7.1
8+
- php: 7.2
9+
- php: 7.3
10+
env: ANALYSIS='true'
11+
- php: nightly
12+
13+
allow_failures:
14+
- php: nightly
15+
16+
before_script:
17+
- composer require php-coveralls/php-coveralls:^2.1.0
18+
- composer install -n
19+
20+
script:
21+
- if [[ "$ANALYSIS" == 'true' ]]; then vendor/bin/phpunit --coverage-clover clover.xml ; fi
22+
23+
after_success:
24+
- if [[ "$ANALYSIS" == 'true' ]]; then vendor/bin/php-coveralls --coverage_clover=clover.xml -v ; fi

CONTRIBUTING.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# How to Contribute
2+
3+
## Pull Requests
4+
5+
1. Fork the Slim Skeleton repository
6+
2. Create a new branch for each feature or improvement
7+
3. Send a pull request from each feature branch to the **4.x** branch
8+
9+
It is very important to separate new features or improvements into separate feature branches, and to send a
10+
pull request for each branch. This allows us to review and pull in new features or improvements individually.
11+
12+
## Style Guide
13+
14+
All pull requests must adhere to the [PSR-2 standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md).

app/dependencies.php

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
use DI\ContainerBuilder;
5+
use Monolog\Handler\StreamHandler;
6+
use Monolog\Logger;
7+
use Monolog\Processor\UidProcessor;
8+
use Psr\Container\ContainerInterface;
9+
use Psr\Log\LoggerInterface;
10+
11+
return function (ContainerBuilder $containerBuilder) {
12+
$containerBuilder->addDefinitions([
13+
LoggerInterface::class => function (ContainerInterface $c) {
14+
$settings = $c->get('settings');
15+
16+
$loggerSettings = $settings['logger'];
17+
$logger = new Logger($loggerSettings['name']);
18+
19+
$processor = new UidProcessor();
20+
$logger->pushProcessor($processor);
21+
22+
$handler = new StreamHandler($loggerSettings['path'], $loggerSettings['level']);
23+
$logger->pushHandler($handler);
24+
25+
return $logger;
26+
},
27+
]);
28+
};

app/middleware.php

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
use App\Application\Middleware\SessionMiddleware;
5+
use Slim\App;
6+
7+
return function (App $app) {
8+
$app->add(SessionMiddleware::class);
9+
};

app/repositories.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
use App\Domain\User\UserRepository;
5+
use App\Infrastructure\Persistence\User\InMemoryUserRepository;
6+
use DI\ContainerBuilder;
7+
8+
return function (ContainerBuilder $containerBuilder) {
9+
// Here we map our UserRepository interface to its in memory implementation
10+
$containerBuilder->addDefinitions([
11+
UserRepository::class => \DI\autowire(InMemoryUserRepository::class),
12+
]);
13+
};

app/routes.php

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
use App\Application\Actions\User\ListUsersAction;
5+
use App\Application\Actions\User\ViewUserAction;
6+
use Psr\Http\Message\ResponseInterface as Response;
7+
use Psr\Http\Message\ServerRequestInterface as Request;
8+
use Slim\App;
9+
use Slim\Interfaces\RouteCollectorProxyInterface as Group;
10+
11+
return function (App $app) {
12+
$app->get('/', function (Request $request, Response $response) {
13+
$response->getBody()->write('Hello world!');
14+
return $response;
15+
});
16+
17+
$app->group('/users', function (Group $group) {
18+
$group->get('', ListUsersAction::class);
19+
$group->get('/{id}', ViewUserAction::class);
20+
});
21+
};

app/settings.php

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
use DI\ContainerBuilder;
5+
use Monolog\Logger;
6+
7+
return function (ContainerBuilder $containerBuilder) {
8+
// Global Settings Object
9+
$containerBuilder->addDefinitions([
10+
'settings' => [
11+
'displayErrorDetails' => true, // Should be set to false in production
12+
'logger' => [
13+
'name' => 'slim-app',
14+
'path' => isset($_ENV['docker']) ? 'php://stdout' : __DIR__ . '/../logs/app.log',
15+
'level' => Logger::DEBUG,
16+
],
17+
],
18+
]);
19+
};

composer.json

+50-16
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,53 @@
11
{
2-
"name": "jefferson/api-slim-framework",
3-
"license": "mit",
4-
"authors": [
5-
{
6-
"name": "Jefferson Miranda",
7-
"email": "[email protected]"
2+
"name": "slim/slim-skeleton",
3+
"description": "A Slim Framework skeleton application for rapid development",
4+
"keywords": [
5+
"microframework",
6+
"rest",
7+
"router",
8+
"psr7"
9+
],
10+
"homepage": "http://github.com/slimphp/Slim-Skeleton",
11+
"license": "MIT",
12+
"authors": [
13+
{
14+
"name": "Josh Lockhart",
15+
"email": "[email protected]",
16+
"homepage": "http://www.joshlockhart.com/"
17+
},
18+
{
19+
"name": "Pierre Berube",
20+
"email": "[email protected]",
21+
"homepage": "http://www.lgse.com/"
22+
}
23+
],
24+
"require": {
25+
"ext-json": "*",
26+
"monolog/monolog": "^1.24",
27+
"php": ">=7.1",
28+
"php-di/php-di": "^6.0",
29+
"slim/psr7": "^0.5",
30+
"slim/slim": "^4.1"
31+
},
32+
"require-dev": {
33+
"phpunit/phpunit": "^7.5"
34+
},
35+
"config": {
36+
"process-timeout": 0,
37+
"sort-packages": true
38+
},
39+
"autoload": {
40+
"psr-4": {
41+
"App\\": "src/"
42+
}
43+
},
44+
"autoload-dev": {
45+
"psr-4": {
46+
"Tests\\": "tests/"
47+
}
48+
},
49+
"scripts": {
50+
"start": "php -S localhost:8080 -t public",
51+
"test": "phpunit"
852
}
9-
],
10-
"autoload": {
11-
"psr-4": {
12-
"api\\" : "src"
13-
}
14-
},
15-
"require": {
16-
"slim/slim": "4.*",
17-
"slim/psr7": "^1.0"
18-
}
1953
}

0 commit comments

Comments
 (0)