Skip to content

Commit dbd0311

Browse files
Basic setup with User entity, repository and user provider
0 parents  commit dbd0311

File tree

35 files changed

+4422
-0
lines changed

35 files changed

+4422
-0
lines changed

.env.dist

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This file is a "template" of which env vars need to be defined for your application
2+
# Copy this file to .env file for development, create environment variables when deploying to production
3+
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
4+
5+
###> symfony/framework-bundle ###
6+
APP_ENV=dev
7+
APP_SECRET=cc3d4aecd8aa414ca1cfc969839807f4
8+
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
9+
#TRUSTED_HOSTS=localhost,example.com
10+
###< symfony/framework-bundle ###
11+
12+
###> doctrine/doctrine-bundle ###
13+
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
14+
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
15+
# Configure your db driver and server_version in config/packages/doctrine.yaml
16+
DATABASE_URL=mysql://db_user:[email protected]:3306/db_name
17+
###< doctrine/doctrine-bundle ###

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
###> symfony/framework-bundle ###
3+
/.env
4+
/public/bundles/
5+
/var/
6+
/vendor/
7+
###< symfony/framework-bundle ###
8+
.idea/

bin/console

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
use App\Kernel;
5+
use Symfony\Bundle\FrameworkBundle\Console\Application;
6+
use Symfony\Component\Console\Input\ArgvInput;
7+
use Symfony\Component\Debug\Debug;
8+
use Symfony\Component\Dotenv\Dotenv;
9+
10+
set_time_limit(0);
11+
12+
require __DIR__.'/../vendor/autoload.php';
13+
14+
if (!class_exists(Application::class)) {
15+
throw new \RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
16+
}
17+
18+
if (!isset($_SERVER['APP_ENV'])) {
19+
if (!class_exists(Dotenv::class)) {
20+
throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
21+
}
22+
(new Dotenv())->load(__DIR__.'/../.env');
23+
}
24+
25+
$input = new ArgvInput();
26+
$env = $input->getParameterOption(['--env', '-e'], $_SERVER['APP_ENV'] ?? 'dev', true);
27+
$debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env)) && !$input->hasParameterOption('--no-debug', true);
28+
29+
if ($debug) {
30+
umask(0000);
31+
32+
if (class_exists(Debug::class)) {
33+
Debug::enable();
34+
}
35+
}
36+
37+
$kernel = new Kernel($env, $debug);
38+
$application = new Application($kernel);
39+
$application->run($input);
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
###############################################################################
2+
# Generated on phpdocker.io #
3+
###############################################################################
4+
version: "3.1"
5+
services:
6+
7+
memcached:
8+
image: memcached:alpine
9+
container_name: symfony-oauth2-server-memcached
10+
11+
redis:
12+
image: redis:alpine
13+
container_name: symfony-oauth2-server-redis
14+
15+
mysql:
16+
image: mysql:5.7
17+
container_name: symfony-oauth2-server-mysql
18+
working_dir: /application
19+
volumes:
20+
- ../../../:/application
21+
environment:
22+
- MYSQL_ROOT_PASSWORD=root
23+
- MYSQL_DATABASE=symfony
24+
- MYSQL_USER=symfony
25+
- MYSQL_PASSWORD=symfony
26+
ports:
27+
- "8082:3306"
28+
29+
webserver:
30+
image: nginx:alpine
31+
container_name: symfony-oauth2-server-webserver
32+
working_dir: /application
33+
volumes:
34+
- ../../../:/application
35+
- ./phpdocker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
36+
ports:
37+
- "8080:80"
38+
39+
php-fpm:
40+
build: phpdocker/php-fpm
41+
environment:
42+
PHP_IDE_CONFIG: "serverName=my.docker"
43+
container_name: symfony-oauth2-server-php-fpm
44+
working_dir: /application
45+
volumes:
46+
- ../../../:/application
47+
- ./phpdocker/php-fpm/php-ini-overrides.ini:/etc/php/7.2/fpm/conf.d/99-overrides.ini
48+
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<html>
2+
<head>
3+
<title>PHPDocker.io Readme</title>
4+
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css">
5+
6+
<style>
7+
code {
8+
background-color : #ddd;
9+
padding : 2px 5px;
10+
font-family : monospace;
11+
font-size : 16px;
12+
}
13+
</style>
14+
</head>
15+
<body>
16+
17+
<div class="pure-g">
18+
<div class="pure-u-1-24"></div>
19+
<div class="pure-u-22-24">
20+
<h1>PHPDocker.io generated environment</h1>
21+
22+
<h1>Add to your project</h1>
23+
24+
<p>Simply, unzip the file into your project, this will create <code>docker-compose.yml</code> on the root of your project and a folder named <code>phpdocker</code> containing nginx and php-fpm config for it.</p>
25+
26+
<p>Ensure the webserver config on <code>docker\nginx.conf</code> is correct for your project. PHPDocker.io will have customised this file according to the application type you chose on the generator, for instance <code>web/app|app_dev.php</code> on a Symfony project, or <code>public/index.php</code> on generic apps.</p>
27+
28+
<p>Note: you may place the files elsewhere in your project. Make sure you modify the locations for the php-fpm dockerfile, the php.ini overrides and nginx config on <code>docker-compose.yml</code> if you do so.</p>
29+
30+
<h1>How to run</h1>
31+
32+
<p>Dependencies:</p>
33+
34+
<ul>
35+
<li>Docker engine v1.13 or higher. Your OS provided package might be a little old, if you encounter problems, do upgrade. See <a href="https://docs.docker.com/engine/installation">https://docs.docker.com/engine/installation</a></li>
36+
<li>Docker compose v1.12 or higher. See <a href="https://docs.docker.com/compose/install/">docs.docker.com/compose/install</a></li>
37+
</ul>
38+
39+
<p>Once you're done, simply <code>cd</code> to your project and run <code>docker-compose up -d</code>. This will initialise and start all the containers, then leave them running in the background.</p>
40+
41+
<h2>Services exposed outside your environment</h2>
42+
43+
<p>You can access your application via <strong><code>localhost</code></strong>, if you're running the containers directly, or through <strong>``</strong> when run on a vm. nginx and mailhog both respond to any hostname, in case you want to add your own hostname on your <code>/etc/hosts</code></p>
44+
45+
<table>
46+
<thead>
47+
<tr>
48+
<th>Service</th>
49+
<th>Address outside containers</th>
50+
</tr>
51+
</thead>
52+
<tbody>
53+
<tr>
54+
<td>Webserver</td>
55+
<td><a href="http://localhost:8080">localhost:8080</a></td>
56+
</tr>
57+
<tr>
58+
<td>MySQL</td>
59+
<td><strong>host:</strong> <code>localhost</code>; <strong>port:</strong> <code>8082</code></td>
60+
</tr>
61+
</tbody>
62+
</table>
63+
64+
<h2>Hosts within your environment</h2>
65+
66+
<p>You'll need to configure your application to use any services you enabled:</p>
67+
68+
<table>
69+
<thead>
70+
<tr>
71+
<th>Service</th>
72+
<th>Hostname</th>
73+
<th>Port number</th>
74+
</tr>
75+
</thead>
76+
<tbody>
77+
<tr>
78+
<td>php-fpm</td>
79+
<td>php-fpm</td>
80+
<td>9000</td>
81+
</tr>
82+
<tr>
83+
<td>MySQL</td>
84+
<td>mysql</td>
85+
<td>3306 (default)</td>
86+
</tr>
87+
<tr>
88+
<td>Memcached</td>
89+
<td>memcached</td>
90+
<td>11211 (default)</td>
91+
</tr>
92+
<tr>
93+
<td>Redis</td>
94+
<td>redis</td>
95+
<td>6379 (default)</td>
96+
</tr>
97+
</tbody>
98+
</table>
99+
100+
<h1>Docker compose cheatsheet</h1>
101+
102+
<p><strong>Note:</strong> you need to cd first to where your docker-compose.yml file lives.</p>
103+
104+
<ul>
105+
<li>Start containers in the background: <code>docker-compose up -d</code></li>
106+
<li>Start containers on the foreground: <code>docker-compose up</code>. You will see a stream of logs for every container running.</li>
107+
<li>Stop containers: <code>docker-compose stop</code></li>
108+
<li>Kill containers: <code>docker-compose kill</code></li>
109+
<li>View container logs: <code>docker-compose logs</code></li>
110+
<li>Execute command inside of container: <code>docker-compose exec SERVICE_NAME COMMAND</code> where <code>COMMAND</code> is whatever you want to run. Examples:
111+
* Shell into the PHP container, <code>docker-compose exec php-fpm bash</code>
112+
* Run symfony console, <code>docker-compose exec php-fpm bin/console</code>
113+
* Open a mysql shell, <code>docker-compose exec mysql mysql -uroot -pCHOSEN_ROOT_PASSWORD</code></li>
114+
</ul>
115+
116+
<h1>Recommendations</h1>
117+
118+
<p>It's hard to avoid file permission issues when fiddling about with containers due to the fact that, from your OS point of view, any files created within the container are owned by the process that runs the docker engine (this is usually root). Different OS will also have different problems, for instance you can run stuff in containers using <code>docker exec -it -u $(id -u):$(id -g) CONTAINER_NAME COMMAND</code> to force your current user ID into the process, but this will only work if your host OS is Linux, not mac. Follow a couple of simple rules and save yourself a world of hurt.</p>
119+
120+
<ul>
121+
<li>Run composer outside of the php container, as doing so would install all your dependencies owned by <code>root</code> within your vendor folder.</li>
122+
<li>Run commands (ie Symfony's console, or Laravel's artisan) straight inside of your container. You can easily open a shell as described above and do your thing from there.</li>
123+
</ul>
124+
</div>
125+
<div class="pure-u-1-24"></div>
126+
</div>
127+
128+
<script>
129+
var tables = document.getElementsByTagName('table');
130+
for (var i = 0; i < tables.length; i++) {
131+
tables[i].className = "pure-table";
132+
}
133+
</script>
134+
</body>
135+
</html>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
PHPDocker.io generated environment
2+
==================================
3+
4+
# Add to your project #
5+
6+
Simply, unzip the file into your project, this will create `docker-compose.yml` on the root of your project and a folder named `phpdocker` containing nginx and php-fpm config for it.
7+
8+
Ensure the webserver config on `docker\nginx.conf` is correct for your project. PHPDocker.io will have customised this file according to the application type you chose on the generator, for instance `web/app|app_dev.php` on a Symfony project, or `public/index.php` on generic apps.
9+
10+
Note: you may place the files elsewhere in your project. Make sure you modify the locations for the php-fpm dockerfile, the php.ini overrides and nginx config on `docker-compose.yml` if you do so.
11+
12+
# How to run #
13+
14+
Dependencies:
15+
16+
* Docker engine v1.13 or higher. Your OS provided package might be a little old, if you encounter problems, do upgrade. See [https://docs.docker.com/engine/installation](https://docs.docker.com/engine/installation)
17+
* Docker compose v1.12 or higher. See [docs.docker.com/compose/install](https://docs.docker.com/compose/install/)
18+
19+
Once you're done, simply `cd` to your project and run `docker-compose up -d`. This will initialise and start all the containers, then leave them running in the background.
20+
21+
## Services exposed outside your environment ##
22+
23+
You can access your application via **`localhost`**, if you're running the containers directly, or through **``** when run on a vm. nginx and mailhog both respond to any hostname, in case you want to add your own hostname on your `/etc/hosts`
24+
25+
Service|Address outside containers
26+
------|---------|-----------
27+
Webserver|[localhost:8080](http://localhost:8080)
28+
MySQL|**host:** `localhost`; **port:** `8082`
29+
30+
## Hosts within your environment ##
31+
32+
You'll need to configure your application to use any services you enabled:
33+
34+
Service|Hostname|Port number
35+
------|---------|-----------
36+
php-fpm|php-fpm|9000
37+
MySQL|mysql|3306 (default)
38+
Memcached|memcached|11211 (default)
39+
Redis|redis|6379 (default)
40+
41+
# Docker compose cheatsheet #
42+
43+
**Note:** you need to cd first to where your docker-compose.yml file lives.
44+
45+
* Start containers in the background: `docker-compose up -d`
46+
* Start containers on the foreground: `docker-compose up`. You will see a stream of logs for every container running.
47+
* Stop containers: `docker-compose stop`
48+
* Kill containers: `docker-compose kill`
49+
* View container logs: `docker-compose logs`
50+
* Execute command inside of container: `docker-compose exec SERVICE_NAME COMMAND` where `COMMAND` is whatever you want to run. Examples:
51+
* Shell into the PHP container, `docker-compose exec php-fpm bash`
52+
* Run symfony console, `docker-compose exec php-fpm bin/console`
53+
* Open a mysql shell, `docker-compose exec mysql mysql -uroot -pCHOSEN_ROOT_PASSWORD`
54+
55+
# Recommendations #
56+
57+
It's hard to avoid file permission issues when fiddling about with containers due to the fact that, from your OS point of view, any files created within the container are owned by the process that runs the docker engine (this is usually root). Different OS will also have different problems, for instance you can run stuff in containers using `docker exec -it -u $(id -u):$(id -g) CONTAINER_NAME COMMAND` to force your current user ID into the process, but this will only work if your host OS is Linux, not mac. Follow a couple of simple rules and save yourself a world of hurt.
58+
59+
* Run composer outside of the php container, as doing so would install all your dependencies owned by `root` within your vendor folder.
60+
* Run commands (ie Symfony's console, or Laravel's artisan) straight inside of your container. You can easily open a shell as described above and do your thing from there.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
server {
2+
listen 80 default;
3+
4+
client_max_body_size 108M;
5+
6+
access_log /var/log/nginx/application.access.log;
7+
8+
9+
root /application/public;
10+
index index.php;
11+
12+
if (!-e $request_filename) {
13+
rewrite ^.*$ /index.php last;
14+
}
15+
16+
location ~ \.php$ {
17+
fastcgi_pass php-fpm:9000;
18+
fastcgi_index index.php;
19+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
20+
fastcgi_param PHP_VALUE "error_log=/var/log/nginx/application_php_errors.log";
21+
fastcgi_buffers 16 16k;
22+
fastcgi_buffer_size 32k;
23+
include fastcgi_params;
24+
}
25+
26+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM phpdockerio/php72-fpm:latest
2+
WORKDIR "/application"
3+
4+
# Install selected extensions and other stuff
5+
RUN apt-get update \
6+
&& apt-get -y --no-install-recommends install php-memcached php7.2-mysql php-redis php7.2-sqlite3 php-xdebug \
7+
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
upload_max_filesize = 100M
2+
post_max_size = 108M
3+
xdebug.idekey = "PHPSTORM"
4+
xdebug.remote_autostart = 1;
5+
xdebug.remote_connect_back = 0;
6+
xdebug.remote_enable = 1
7+
xdebug.remote_host = 192.168.0.157
8+
xdebug.remote_log="/tmp/xdebug.log"
9+
PHP_IDE_CONFIG="serverName=docker"

0 commit comments

Comments
 (0)