Skip to content

Commit

Permalink
check-guide
Browse files Browse the repository at this point in the history
  • Loading branch information
Byidi committed Jan 17, 2023
1 parent 309e06b commit 6de7f76
Show file tree
Hide file tree
Showing 40 changed files with 1,280 additions and 70 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -728,3 +728,36 @@ jobs:
run: tests/Fixtures/app/console cache:clear --ansi
- name: Run Behat tests
run: vendor/bin/behat --out=std --format=progress --profile=default --no-interaction

checkguide:
runs-on: ubuntu-latest
strategy:
matrix:
php:
- '8.1'
fail-fast: false
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: intl, bcmath, curl, openssl, mbstring
ini-values: memory_limit=-1
tools: pecl, composer
coverage: none
- name: Get composer cache directory
id: composercache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Update project dependencies
run: cd docs && composer update --no-interaction --no-progress --ansi
- name: Run check command
run: cd docs && make check
24 changes: 24 additions & 0 deletions docs/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# In all environments, the following files are loaded if they exist,
# the latter taking precedence over the former:
#
# * .env contains default values for the environment variables needed by the app
# * .env.local uncommitted file with local overrides
# * .env.$APP_ENV committed environment-specific defaults
# * .env.$APP_ENV.local uncommitted environment-specific overrides
#
# Real environment variables win over .env files.
#
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
# https://symfony.com/doc/current/configuration/secrets.html
#
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration

###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=ab0da85135bd245202dd6c8de5b90aa9
###< symfony/framework-bundle ###

###> nelmio/cors-bundle ###
CORS_ALLOW_ORIGIN='^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$'
###< nelmio/cors-bundle ###
6 changes: 6 additions & 0 deletions docs/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# define your env variables for the test env here
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
PANTHER_APP_ENV=panther
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
20 changes: 20 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,23 @@ node_modules
composer.lock
vendor
var

###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###

###> phpunit/phpunit ###
/phpunit.xml
.phpunit.result.cache
###< phpunit/phpunit ###

###> symfony/phpunit-bridge ###
.phpunit.result.cache
/phpunit.xml
###< symfony/phpunit-bridge ###
6 changes: 6 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ guide:
./bin/pdg pdg:guide "$$d" > "pages/guide/$$name.mdx"; \
done

check:
for d in ./guide/*.php; do \
name=$$(basename $$d .php); \
./bin/pdg pdg:check:guide "$$d"; \
done

index:
./bin/pdg pdg:index > "pages/sidebar.mdx"

Expand Down
12 changes: 7 additions & 5 deletions docs/bin/pdg
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
use PDG\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;

require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}

return function (array $context) {
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

// returning an "Application" makes the Runtime run a Console
// application instead of the HTTP Kernel
return function (array $context, string $guide = '') {
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG'], $guide);

return new Application($kernel);
};
41 changes: 37 additions & 4 deletions docs/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,57 @@
"psr-4": {
"PDG\\": "src/",
"ApiPlatform\\": "../src"
}
},
"files": [
"src/Command/CheckGuideCommand.php",
"src/Command/PhpUnitCommand.php",
"src/Command/TestGuideCommand.php"
]
},
"require-dev": {
"symfony/dom-crawler": "^6.2",
"phpstan/phpdoc-parser": "^1.15",
"symfony/serializer": "^6.2",
"nikic/php-parser": "^4.15"
"nikic/php-parser": "^4.15",
"dama/doctrine-test-bundle": "^7.1",
"justinrainbow/json-schema": "^5.2",
"phpunit/phpunit": "^9.5",
"symfony/browser-kit": "^6.2",
"symfony/css-selector": "^6.2",
"symfony/http-client": "^6.2",
"symfony/phpunit-bridge": "^6.2"
},
"require": {
"symfony/runtime": "^6.2",
"symfony/console": "^6.2",
"symfony/http-kernel": "^6.2",
"symfony/framework-bundle": "^6.2",
"spatie/yaml-front-matter": "^2.0"
"spatie/yaml-front-matter": "^2.0",
"symfony/property-info": "^6.2",
"symfony/property-access": "^6.2",
"symfony/flex": "^2.2",
"nelmio/cors-bundle": "^2.2",
"symfony/security-bundle": "^6.2",
"willdurand/negotiation": "^3.1",
"symfony/twig-bundle": "^6.2",
"symfony/web-link": "^6.2",
"doctrine/annotations": "^2.0",
"doctrine/doctrine-bundle": "^2.8",
"doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.14",
"doctrine/doctrine-fixtures-bundle": "^3.4",
"symfony/validator": "^6.2"
},
"config": {
"allow-plugins": {
"symfony/runtime": true
"symfony/runtime": true,
"symfony/flex": true
}
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
}
}
}
13 changes: 13 additions & 0 deletions docs/config/bundles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
ApiPlatform\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
DAMA\DoctrineTestBundle\DAMADoctrineTestBundle::class => ['test' => true],
];
10 changes: 10 additions & 0 deletions docs/config/packages/api_platform.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
api_platform:
formats:
json: [ 'application/json' ]
jsonld: [ 'application/ld+json' ]

# mapping:
# paths:
# - '%kernel.project_dir%/src'
# doctrine:
# enabled: true
19 changes: 19 additions & 0 deletions docs/config/packages/cache.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
framework:
cache:
# Unique name of your app: used to compute stable namespaces for cache keys.
#prefix_seed: your_vendor_name/app_name

# The "app" cache stores to the filesystem by default.
# The data in this cache should persist between deploys.
# Other options include:

# Redis
#app: cache.adapter.redis
#default_redis_provider: redis://localhost

# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
#app: cache.adapter.apcu

# Namespaced pools use the above "app" backend by default
#pools:
#my.dedicated.cache: null
43 changes: 43 additions & 0 deletions docs/config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
doctrine:
dbal:
url: '%database_url%'

# IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file)
#server_version: '14'
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
is_bundle: false
dir: '%kernel.project_dir%/src'
prefix: 'App\Entity'
alias: App

when@test:
doctrine:
dbal:
# "TEST_TOKEN" is typically set by ParaTest
dbname_suffix: '_test%env(default::TEST_TOKEN)%'

when@prod:
doctrine:
orm:
auto_generate_proxy_classes: false
proxy_dir: '%kernel.build_dir%/doctrine/orm/Proxies'
query_cache_driver:
type: pool
pool: doctrine.system_cache_pool
result_cache_driver:
type: pool
pool: doctrine.result_cache_pool

framework:
cache:
pools:
doctrine.result_cache_pool:
adapter: cache.app
doctrine.system_cache_pool:
adapter: cache.system
6 changes: 6 additions & 0 deletions docs/config/packages/doctrine_migrations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
doctrine_migrations:
migrations_paths:
# namespace is arbitrary but should be different from App\Migrations
# as migrations classes should NOT be autoloaded
'DoctrineMigrations': '%kernel.project_dir%/src'
enable_profiler: false
25 changes: 25 additions & 0 deletions docs/config/packages/framework.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# see https://symfony.com/doc/current/reference/configuration/framework.html
framework:
secret: '%env(APP_SECRET)%'
#csrf_protection: true
http_method_override: false
handle_all_throwables: true

# Enables session support. Note that the session will ONLY be started if you read or write from it.
# Remove or comment this section to explicitly disable session support.
session:
handler_id: null
cookie_secure: auto
cookie_samesite: lax
storage_factory_id: session.storage.factory.native

#esi: true
#fragments: true
php_errors:
log: true

when@test:
framework:
test: true
session:
storage_factory_id: session.storage.factory.mock_file
10 changes: 10 additions & 0 deletions docs/config/packages/nelmio_cors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
nelmio_cors:
defaults:
origin_regex: true
allow_origin: ['^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$']
allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
allow_headers: ['Content-Type', 'Authorization']
expose_headers: ['Link']
max_age: 3600
paths:
'^/': null
12 changes: 12 additions & 0 deletions docs/config/packages/routing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
framework:
router:
utf8: true

# Configure how to generate URLs in non-HTTP contexts, such as CLI commands.
# See https://symfony.com/doc/current/routing.html#generating-urls-in-commands
#default_uri: http://localhost

when@prod:
framework:
router:
strict_requirements: null
39 changes: 39 additions & 0 deletions docs/config/packages/security.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
security:
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
password_hashers:
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
providers:
users_in_memory: { memory: null }
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
lazy: true
provider: users_in_memory

# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#the-firewall

# https://symfony.com/doc/current/security/impersonating_user.html
# switch_user: true

# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
# - { path: ^/admin, roles: ROLE_ADMIN }
# - { path: ^/profile, roles: ROLE_USER }

when@test:
security:
password_hashers:
# By default, password hashers are resource intensive and take time. This is
# important to generate secure password hashes. In tests however, secure hashes
# are not important, waste resources and increase test times. The following
# reduces the work factor to the lowest possible values.
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface:
algorithm: auto
cost: 4 # Lowest possible value for bcrypt
time_cost: 3 # Lowest possible value for argon
memory_cost: 10 # Lowest possible value for argon
6 changes: 6 additions & 0 deletions docs/config/packages/twig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
twig:
default_path: '%kernel.project_dir%/templates'

when@test:
twig:
strict_variables: true
13 changes: 13 additions & 0 deletions docs/config/packages/validator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
framework:
validation:
email_validation_mode: html5

# Enables validator auto-mapping support.
# For instance, basic validation constraints will be inferred from Doctrine's metadata.
#auto_mapping:
# App\Entity\: []

when@test:
framework:
validation:
not_compromised_password: false
Loading

0 comments on commit 6de7f76

Please sign in to comment.