added orm

This commit is contained in:
tracer 2021-05-30 17:34:33 +02:00
parent 7f1aea6c8a
commit 914f19c043
15 changed files with 2626 additions and 160 deletions

9
.env
View File

@ -17,3 +17,12 @@
APP_ENV=dev
APP_SECRET=cd0ae68f915f2a06b82007f2906e54e8
###< symfony/framework-bundle ###
###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
# DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7"
DATABASE_URL="postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=13&charset=utf8"
###< doctrine/doctrine-bundle ###

View File

@ -4,14 +4,20 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=7.2.5",
"php": ">=8.0",
"ext-ctype": "*",
"ext-iconv": "*",
"composer/package-versions-deprecated": "1.11.99.2",
"doctrine/annotations": "^1.13",
"doctrine/doctrine-bundle": "^2.3",
"doctrine/doctrine-migrations-bundle": "^3.1",
"doctrine/orm": "^2.9",
"symfony/console": "5.2.*",
"symfony/dotenv": "5.2.*",
"symfony/flex": "^1.3.1",
"symfony/framework-bundle": "5.2.*",
"symfony/proxy-manager-bridge": "5.2.*",
"symfony/security-bundle": "5.2.*",
"symfony/yaml": "5.2.*"
},
"require-dev": {

2540
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -5,4 +5,7 @@ return [
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
];

View File

@ -0,0 +1,18 @@
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'
# IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file)
#server_version: '13'
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App

View File

@ -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%/migrations'
enable_profiler: '%kernel.debug%'

View File

@ -0,0 +1,20 @@
doctrine:
orm:
auto_generate_proxy_classes: false
metadata_cache_driver:
type: pool
pool: doctrine.system_cache_pool
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

View File

@ -0,0 +1,24 @@
security:
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
users_in_memory: { memory: null }
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: true
lazy: true
provider: users_in_memory
# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#firewalls-authentication
# 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 }

View File

@ -0,0 +1,4 @@
doctrine:
dbal:
# "TEST_TOKEN" is typically set by ParaTest
dbname: 'main_test%env(default::TEST_TOKEN)%'

0
migrations/.gitignore vendored Normal file
View File

View File

@ -0,0 +1,18 @@
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class BlogController extends AbstractController
{
#[Route('/', name: 'blog')]
public function index(): Response
{
return $this->render('blog/index.html.twig', [
'controller_name' => 'BlogController',
]);
}
}

0
src/Entity/.gitignore vendored Normal file
View File

0
src/Repository/.gitignore vendored Normal file
View File

View File

@ -1,4 +1,7 @@
{
"composer/package-versions-deprecated": {
"version": "1.11.99.2"
},
"doctrine/annotations": {
"version": "1.0",
"recipe": {
@ -11,12 +14,86 @@
"config/routes/annotations.yaml"
]
},
"doctrine/cache": {
"version": "2.0.3"
},
"doctrine/collections": {
"version": "1.6.7"
},
"doctrine/common": {
"version": "3.1.2"
},
"doctrine/dbal": {
"version": "2.13.x-dev"
},
"doctrine/deprecations": {
"version": "v0.5.3"
},
"doctrine/doctrine-bundle": {
"version": "2.3",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "2.3",
"ref": "c9e656a395646ea4fad2bd3e2b3816028baf9026"
},
"files": [
"config/packages/doctrine.yaml",
"config/packages/prod/doctrine.yaml",
"config/packages/test/doctrine.yaml",
"src/Entity/.gitignore",
"src/Repository/.gitignore"
]
},
"doctrine/doctrine-migrations-bundle": {
"version": "3.1",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "3.1",
"ref": "ee609429c9ee23e22d6fa5728211768f51ed2818"
},
"files": [
"config/packages/doctrine_migrations.yaml",
"migrations/.gitignore"
]
},
"doctrine/event-manager": {
"version": "1.1.1"
},
"doctrine/inflector": {
"version": "2.0.3"
},
"doctrine/instantiator": {
"version": "1.4.0"
},
"doctrine/lexer": {
"version": "1.2.1"
},
"doctrine/migrations": {
"version": "3.1.2"
},
"doctrine/orm": {
"version": "2.9.1"
},
"doctrine/persistence": {
"version": "2.2.1"
},
"doctrine/sql-formatter": {
"version": "1.1.1"
},
"friendsofphp/proxy-manager-lts": {
"version": "v1.0.5"
},
"laminas/laminas-code": {
"version": "4.3.0"
},
"laminas/laminas-eventmanager": {
"version": "3.3.1"
},
"laminas/laminas-zendframework-bridge": {
"version": "1.2.0"
},
"nikic/php-parser": {
"version": "v4.10.5"
},
@ -59,6 +136,9 @@
"symfony/deprecation-contracts": {
"version": "v2.4.0"
},
"symfony/doctrine-bridge": {
"version": "v5.2.9"
},
"symfony/dotenv": {
"version": "v5.2.4"
},
@ -127,6 +207,9 @@
"ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f"
}
},
"symfony/orm-pack": {
"version": "v2.1.0"
},
"symfony/polyfill-intl-grapheme": {
"version": "v1.23.0"
},
@ -145,6 +228,15 @@
"symfony/profiler-pack": {
"version": "v1.0.5"
},
"symfony/property-access": {
"version": "v5.2.4"
},
"symfony/property-info": {
"version": "v5.2.8"
},
"symfony/proxy-manager-bridge": {
"version": "v5.2.9"
},
"symfony/routing": {
"version": "5.1",
"recipe": {
@ -159,6 +251,30 @@
"config/routes.yaml"
]
},
"symfony/security-bundle": {
"version": "5.1",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "5.1",
"ref": "0a4bae19389d3b9cba1ca0102e3b2bccea724603"
},
"files": [
"config/packages/security.yaml"
]
},
"symfony/security-core": {
"version": "v5.2.9"
},
"symfony/security-csrf": {
"version": "v5.2.7"
},
"symfony/security-guard": {
"version": "v5.2.8"
},
"symfony/security-http": {
"version": "v5.2.9"
},
"symfony/service-contracts": {
"version": "v2.4.0"
},

View File

@ -0,0 +1,20 @@
{% extends 'base.html.twig' %}
{% block title %}Hello BlogController!{% endblock %}
{% block body %}
<style>
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
</style>
<div class="example-wrapper">
<h1>Hello {{ controller_name }}! ✅</h1>
This friendly message is coming from:
<ul>
<li>Your controller at <code><a href="{{ '/Users/tracer/Projects/24unix.net/24unix.net_web/24unix/src/Controller/BlogController.php'|file_link(0) }}">src/Controller/BlogController.php</a></code></li>
<li>Your template at <code><a href="{{ '/Users/tracer/Projects/24unix.net/24unix.net_web/24unix/templates/blog/index.html.twig'|file_link(0) }}">templates/blog/index.html.twig</a></code></li>
</ul>
</div>
{% endblock %}