Skip to content

Commit 850dcb5

Browse files
Begin example app
1 parent 012bf70 commit 850dcb5

28 files changed

+681
-0
lines changed

.github/workflows/example-app.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Example App
2+
3+
on:
4+
push:
5+
branches: [ main, example-app ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
services:
14+
postgres:
15+
image: postgres:16-alpine
16+
env:
17+
POSTGRES_USER: test
18+
POSTGRES_DB: test
19+
POSTGRES_HOST_AUTH_METHOD: trust
20+
ports:
21+
- 5432:5432
22+
options: >-
23+
--health-cmd pg_isready
24+
--health-interval 10s
25+
--health-timeout 5s
26+
--health-retries 5
27+
28+
steps:
29+
- uses: actions/checkout@v3
30+
31+
- name: Set up PHP
32+
uses: shivammathur/setup-php@v2
33+
with:
34+
php-version: '8.2'
35+
extensions: pgsql, pdo_pgsql
36+
37+
- name: Install PostgreSQL client
38+
run: sudo apt-get update && sudo apt-get install -y postgresql-client
39+
40+
- name: Install dependencies
41+
run: composer install --working-dir=docs/example --prefer-dist --no-progress
42+
43+
- name: Create test_test database
44+
env:
45+
PGPASSWORD: ""
46+
run: createdb -h localhost -p 5432 -U test test_test
47+
48+
- name: Run tests
49+
working-directory: docs/example
50+
run: ./vendor/bin/phpunit

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Doctrine CipherSweet Adapter
22

33
[![Build Status](https://github.com/paragonie/doctrine-ciphersweet/actions/workflows/ci.yml/badge.svg)](https://github.com/paragonie/doctrine-ciphersweet/actions)
4+
[![Example App](https://github.com/paragonie/doctrine-ciphersweet/actions/workflows/example-app.yml/badge.svg)](https://github.com/paragonie/doctrine-ciphersweet/tree/main/docs/example-app)
45
[![Static Analysis](https://github.com/paragonie/doctrine-ciphersweet/actions/workflows/psalm.yml/badge.svg)](https://github.com/paragonie/doctrine-ciphersweet/actions)
56
[![Latest Stable Version](https://poser.pugx.org/paragonie/doctrine-ciphersweet/v/stable)](https://packagist.org/packages/paragonie/doctrine-cipher)
67
[![Latest Unstable Version](https://poser.pugx.org/paragonie/doctrine-ciphersweet/v/unstable)](https://packagist.org/packages/paragonie/doctrine-cipher)

docs/example/.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# editorconfig.org
2+
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
end_of_line = lf
8+
indent_size = 4
9+
indent_style = space
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
13+
[{compose.yaml,compose.*.yaml}]
14+
indent_size = 2
15+
16+
[*.md]
17+
trim_trailing_whitespace = false

docs/example/.env

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# In all environments, the following files are loaded if they exist,
2+
# the latter taking precedence over the former:
3+
#
4+
# * .env contains default values for the environment variables needed by the app
5+
# * .env.local uncommitted file with local overrides
6+
# * .env.$APP_ENV committed environment-specific defaults
7+
# * .env.$APP_ENV.local uncommitted environment-specific overrides
8+
#
9+
# Real environment variables win over .env files.
10+
#
11+
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
12+
# https://symfony.com/doc/current/configuration/secrets.html
13+
#
14+
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
15+
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
16+
17+
###> symfony/framework-bundle ###
18+
APP_ENV=dev
19+
APP_SECRET=
20+
###< symfony/framework-bundle ###
21+
22+
###> symfony/routing ###
23+
# Configure how to generate URLs in non-HTTP contexts, such as CLI commands.
24+
# See https://symfony.com/doc/current/routing.html#generating-urls-in-commands
25+
DEFAULT_URI=http://localhost
26+
###< symfony/routing ###
27+
CIPHERSWEET_KEY="2162a5508a829bf6888a7b321c436d6e143525b653e88691b8d2288062534da2"
28+
29+
###> doctrine/doctrine-bundle ###
30+
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
31+
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
32+
#
33+
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data_%kernel.environment%.db"
34+
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8.0.32&charset=utf8mb4"
35+
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
36+
DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=16&charset=utf8"
37+
###< doctrine/doctrine-bundle ###
38+
DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"

docs/example/.env.dev

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
###> symfony/framework-bundle ###
3+
APP_SECRET=bded8759ccede8b520551b62e1cdabde
4+
###< symfony/framework-bundle ###

docs/example/.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/composer.lock
2+
3+
###> symfony/framework-bundle ###
4+
/.env.local
5+
/.env.local.php
6+
/.env.*.local
7+
/config/secrets/prod/prod.decrypt.private.php
8+
/public/bundles/
9+
/symfony.lock
10+
/var/
11+
/vendor/
12+
###< symfony/framework-bundle ###

docs/example/LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) Fabien Potencier
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is furnished
8+
to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

docs/example/bin/console

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
use App\Kernel;
5+
use Symfony\Bundle\FrameworkBundle\Console\Application;
6+
7+
if (!is_dir(dirname(__DIR__).'/vendor')) {
8+
throw new LogicException('Dependencies are missing. Try running "composer install".');
9+
}
10+
11+
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
12+
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
13+
}
14+
15+
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
16+
17+
return function (array $context) {
18+
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
19+
20+
return new Application($kernel);
21+
};

docs/example/composer.json

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
"name": "paragonie/doctrine-ciphersweet-example-app",
3+
"type": "project",
4+
"license": "MIT",
5+
"description": "A minimal Symfony project recommended to create bare bones applications",
6+
"minimum-stability": "stable",
7+
"prefer-stable": true,
8+
"require": {
9+
"php": ">=8.2",
10+
"ext-ctype": "*",
11+
"ext-iconv": "*",
12+
"doctrine/doctrine-bundle": "^2.16.2",
13+
"doctrine/orm": "^3.5.2",
14+
"paragonie/doctrine-ciphersweet": "dev-example-app",
15+
"symfony/console": "7.3.*",
16+
"symfony/dotenv": "7.3.*",
17+
"symfony/expression-language": "7.3.*",
18+
"symfony/flex": "^2.8.2",
19+
"symfony/framework-bundle": "7.3.*",
20+
"symfony/runtime": "7.3.*",
21+
"symfony/yaml": "7.3.*"
22+
},
23+
"require-dev": {
24+
"phpunit/phpunit": "^11|^12",
25+
"symfony/browser-kit": "7.3.*",
26+
"symfony/css-selector": "7.3.*"
27+
},
28+
"config": {
29+
"allow-plugins": {
30+
"php-http/discovery": true,
31+
"symfony/flex": true,
32+
"symfony/runtime": true
33+
},
34+
"bump-after-update": true,
35+
"sort-packages": true
36+
},
37+
"autoload": {
38+
"psr-4": {
39+
"App\\": "src/"
40+
}
41+
},
42+
"autoload-dev": {
43+
"psr-4": {
44+
"App\\Tests\\": "tests/"
45+
}
46+
},
47+
"replace": {
48+
"symfony/polyfill-ctype": "*",
49+
"symfony/polyfill-iconv": "*",
50+
"symfony/polyfill-php72": "*",
51+
"symfony/polyfill-php73": "*",
52+
"symfony/polyfill-php74": "*",
53+
"symfony/polyfill-php80": "*",
54+
"symfony/polyfill-php81": "*",
55+
"symfony/polyfill-php82": "*"
56+
},
57+
"scripts": {
58+
"auto-scripts": {
59+
"cache:clear": "symfony-cmd",
60+
"assets:install %PUBLIC_DIR%": "symfony-cmd"
61+
},
62+
"post-install-cmd": [
63+
"@auto-scripts"
64+
],
65+
"post-update-cmd": [
66+
"@auto-scripts"
67+
]
68+
},
69+
"conflict": {
70+
"symfony/symfony": "*"
71+
},
72+
"extra": {
73+
"symfony": {
74+
"allow-contrib": false,
75+
"require": "7.3.*"
76+
}
77+
}
78+
}

docs/example/config/bundles.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
return [
4+
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
5+
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
6+
];

0 commit comments

Comments
 (0)