Skip to content

Commit 084d62d

Browse files
committed
First commit
1 parent 7a98913 commit 084d62d

Some content is hidden

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

72 files changed

+5435
-0
lines changed

.dockerignore

Whitespace-only changes.

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 4
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
# PHP should follow the PSR-2 standard
13+
# (https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
14+
[*.php]
15+
indent_size = 4

.env

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[docker]
2+
COMPOSE_FILE=docker/docker-compose.yml:docker/docker-compose.local.yml:docker/docker-compose.build.yml
3+
DOCKER_TAG=latest
4+
PROJECT_REPOSITORY=example
5+
6+
[database]
7+
DB_HOST=database
8+
DB_NAME=example_db
9+
DB_USER=example
10+
DB_PASS=some-pass
11+
12+
[mailer]
13+
MAILER_HOST=maildev
14+
MAILER_PORT=25
15+
MAILER_USER=
16+
MAILER_PASS=
17+
18+
[symfony]
19+
SYMFONY_ENV=dev
20+
SECRET=baa7c1ba5e870bd3e4b41957e8a310e3

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/phpunit.xml
2+
/var/*
3+
/vendor/
4+
/docker/nginx/web/bundles/

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Dummy Api
2+
=====================
3+
4+
TBD
5+
6+
## Setup Dev Environment
7+
8+
First of all we need to install dependencies using composer
9+
10+
```
11+
composer install --skip-platform-reqs
12+
```
13+
14+
Then you could run `composer start`.
15+
16+
### XDebug
17+
18+
Unleas you running container using `SYMFONY_ENV=prod` xdebug extension is enabled by default. It uses remote_connect_back option so
19+
you should add server with name `_` in your IDE. You also need to add server and setup [path mappings](https://www.jetbrains.com/help/phpstorm/2016.3/override-server-path-mappings-dialog.html).
20+
21+
As for CLI scripts, you may use `docker/shortcuts/php` as entripoint for all your CLI scripts. This entrypoint
22+
checking `REMOTE_DEBUG_IP` env variable which should contain IP address of your host machine to connect.

app.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
use Symfony\Component\HttpFoundation\Request;
4+
5+
/**
6+
* @var \Composer\Autoload\ClassLoader $loader
7+
*/
8+
$loader = require __DIR__.'/app/autoload.php';
9+
10+
$env = getenv('SYMFONY_ENV') ?: 'prod';
11+
$kernel = new AppKernel($env, $env !== 'prod');
12+
$kernel->boot();
13+
$request = Request::createFromGlobals();
14+
$response = $kernel->handle($request);
15+
$response->send();
16+
$kernel->terminate($request, $response);

app/AppBundle.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace Example;
4+
5+
use Symfony\Component\HttpKernel\Bundle\Bundle;
6+
7+
class AppBundle extends Bundle
8+
{
9+
}

app/AppCache.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
use Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache;
4+
5+
class AppCache extends HttpCache
6+
{
7+
}

app/AppKernel.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
use Symfony\Component\HttpKernel\Kernel;
4+
use Symfony\Component\Config\Loader\LoaderInterface;
5+
6+
class AppKernel extends Kernel
7+
{
8+
use \Fluent\EnableFluentConfig;
9+
10+
public function registerBundles()
11+
{
12+
$bundles = [
13+
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
14+
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
15+
new Symfony\Bundle\TwigBundle\TwigBundle(),
16+
new Symfony\Bundle\MonologBundle\MonologBundle(),
17+
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
18+
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
19+
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
20+
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
21+
new Example\AppBundle(),
22+
];
23+
24+
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
25+
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
26+
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
27+
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
28+
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
29+
}
30+
31+
return $bundles;
32+
}
33+
34+
public function getRootDir()
35+
{
36+
return __DIR__;
37+
}
38+
39+
public function getCacheDir()
40+
{
41+
return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
42+
}
43+
44+
public function getLogDir()
45+
{
46+
return dirname(__DIR__).'/var/logs';
47+
}
48+
49+
public function registerContainerConfiguration(LoaderInterface $loader)
50+
{
51+
$loader->load($this->getRootDir().'/Resources/config/config_'.$this->getEnvironment().'.yml');
52+
}
53+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Example\Common\Security\EventListener;
4+
5+
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
6+
7+
class JwtUserEventListener
8+
{
9+
public function onRequest(GetResponseEvent $event)
10+
{
11+
if (!$event->isMasterRequest()) return;
12+
13+
$request = $event->getRequest();
14+
15+
if (!$request->headers->has('X-Authorization')) return;
16+
17+
$payload = $this->extractPayloadFromToken($request->headers->get('X-Authorization'));
18+
}
19+
20+
private function extractPayloadFromToken($jwt)
21+
{
22+
return [
23+
'id' => '77b80b8a-63ad-4abf-8bac-c34cbfc12558',
24+
'scopes' => ['posts', 'comments'],
25+
];
26+
}
27+
}

0 commit comments

Comments
 (0)