add doctrine
This commit is contained in:
parent
7e1005c9e9
commit
52426489ef
8
.env
8
.env
|
@ -17,3 +17,11 @@
|
|||
APP_ENV=dev
|
||||
APP_SECRET=aa708f7c537a5c6d167229524aea0817
|
||||
###< 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
|
||||
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
|
||||
# For a PostgreSQL database, use: "postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=11&charset=utf8"
|
||||
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
|
||||
DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7
|
||||
###< doctrine/doctrine-bundle ###
|
||||
|
|
|
@ -7,11 +7,17 @@
|
|||
"php": ">=7.2.5",
|
||||
"ext-ctype": "*",
|
||||
"ext-iconv": "*",
|
||||
"composer/package-versions-deprecated": "1.11.99.1",
|
||||
"doctrine/doctrine-bundle": "^2.2",
|
||||
"doctrine/doctrine-migrations-bundle": "^3.0",
|
||||
"doctrine/orm": "^2.7",
|
||||
"php-mime-mail-parser/php-mime-mail-parser": "^6.0",
|
||||
"ramsey/uuid-doctrine": "^1.6",
|
||||
"symfony/console": "5.2.*",
|
||||
"symfony/dotenv": "5.2.*",
|
||||
"symfony/flex": "^1.3.1",
|
||||
"symfony/framework-bundle": "5.2.*",
|
||||
"symfony/maker-bundle": "^1.23",
|
||||
"symfony/yaml": "5.2.*"
|
||||
},
|
||||
"require-dev": {
|
||||
|
|
|
@ -2,4 +2,7 @@
|
|||
|
||||
return [
|
||||
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
|
||||
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
|
||||
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
|
||||
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
|
||||
];
|
||||
|
|
18
config/packages/doctrine.yaml
Normal file
18
config/packages/doctrine.yaml
Normal 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: '5.7'
|
||||
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
|
5
config/packages/doctrine_migrations.yaml
Normal file
5
config/packages/doctrine_migrations.yaml
Normal file
|
@ -0,0 +1,5 @@
|
|||
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'
|
20
config/packages/prod/doctrine.yaml
Normal file
20
config/packages/prod/doctrine.yaml
Normal 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
|
4
config/packages/ramsey_uuid_doctrine.yaml
Normal file
4
config/packages/ramsey_uuid_doctrine.yaml
Normal file
|
@ -0,0 +1,4 @@
|
|||
doctrine:
|
||||
dbal:
|
||||
types:
|
||||
uuid: 'Ramsey\Uuid\Doctrine\UuidType'
|
66
src/Doctrine/Timestampable.php
Normal file
66
src/Doctrine/Timestampable.php
Normal file
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
namespace App\Doctrine;
|
||||
|
||||
trait Timestampable
|
||||
{
|
||||
/**
|
||||
* @var \DateTime
|
||||
*
|
||||
* @ORM\Column(name="created_at", type="datetime")
|
||||
*/
|
||||
private $createdAt;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*
|
||||
* @ORM\Column(name="updated_at", type="datetime")
|
||||
*/
|
||||
private $updatedAt;
|
||||
|
||||
/**
|
||||
* Gets triggered only on insert.
|
||||
*
|
||||
* @ORM\PrePersist
|
||||
*/
|
||||
public function onPrePersist(): void
|
||||
{
|
||||
$this->createdAt = new \DateTime();
|
||||
$this->updatedAt = new \DateTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets triggered every time on update.
|
||||
*
|
||||
* @ORM\PreUpdate
|
||||
*/
|
||||
public function onPreUpdate(): void
|
||||
{
|
||||
$this->updatedAt = new \DateTime();
|
||||
}
|
||||
|
||||
public function setCreatedAt(?\DateTime $createdAt): self
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
|
||||
public function setUpdatedAt(?DateTime $updatedAt): self
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUpdatedAt(): ?\DateTime
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
}
|
136
symfony.lock
136
symfony.lock
|
@ -1,4 +1,101 @@
|
|||
{
|
||||
"brick/math": {
|
||||
"version": "0.9.1"
|
||||
},
|
||||
"composer/package-versions-deprecated": {
|
||||
"version": "1.11.99.1"
|
||||
},
|
||||
"doctrine/annotations": {
|
||||
"version": "1.0",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes",
|
||||
"branch": "master",
|
||||
"version": "1.0",
|
||||
"ref": "a2759dd6123694c8d901d0ec80006e044c2e6457"
|
||||
},
|
||||
"files": [
|
||||
"config/routes/annotations.yaml"
|
||||
]
|
||||
},
|
||||
"doctrine/cache": {
|
||||
"version": "1.10.2"
|
||||
},
|
||||
"doctrine/collections": {
|
||||
"version": "1.6.7"
|
||||
},
|
||||
"doctrine/common": {
|
||||
"version": "3.0.2"
|
||||
},
|
||||
"doctrine/dbal": {
|
||||
"version": "2.12.0"
|
||||
},
|
||||
"doctrine/doctrine-bundle": {
|
||||
"version": "2.0",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes",
|
||||
"branch": "master",
|
||||
"version": "2.0",
|
||||
"ref": "a9f2463b9f73efe74482f831f03a204a41328555"
|
||||
},
|
||||
"files": [
|
||||
"config/packages/doctrine.yaml",
|
||||
"config/packages/prod/doctrine.yaml",
|
||||
"src/Entity/.gitignore",
|
||||
"src/Repository/.gitignore"
|
||||
]
|
||||
},
|
||||
"doctrine/doctrine-migrations-bundle": {
|
||||
"version": "2.2",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes",
|
||||
"branch": "master",
|
||||
"version": "2.2",
|
||||
"ref": "baaa439e3e3179e69e3da84b671f0a3e4a2f56ad"
|
||||
},
|
||||
"files": [
|
||||
"config/packages/doctrine_migrations.yaml",
|
||||
"migrations/.gitignore"
|
||||
]
|
||||
},
|
||||
"doctrine/event-manager": {
|
||||
"version": "1.1.1"
|
||||
},
|
||||
"doctrine/inflector": {
|
||||
"version": "1.4.3"
|
||||
},
|
||||
"doctrine/instantiator": {
|
||||
"version": "1.4.0"
|
||||
},
|
||||
"doctrine/lexer": {
|
||||
"version": "1.2.1"
|
||||
},
|
||||
"doctrine/migrations": {
|
||||
"version": "3.0.1"
|
||||
},
|
||||
"doctrine/orm": {
|
||||
"version": "2.7.4"
|
||||
},
|
||||
"doctrine/persistence": {
|
||||
"version": "2.1.0"
|
||||
},
|
||||
"doctrine/sql-formatter": {
|
||||
"version": "1.1.1"
|
||||
},
|
||||
"laminas/laminas-code": {
|
||||
"version": "3.4.1"
|
||||
},
|
||||
"laminas/laminas-eventmanager": {
|
||||
"version": "3.3.0"
|
||||
},
|
||||
"laminas/laminas-zendframework-bridge": {
|
||||
"version": "1.1.1"
|
||||
},
|
||||
"nikic/php-parser": {
|
||||
"version": "v4.10.2"
|
||||
},
|
||||
"ocramius/proxy-manager": {
|
||||
"version": "2.9.1"
|
||||
},
|
||||
"php": {
|
||||
"version": "7.4"
|
||||
},
|
||||
|
@ -17,6 +114,24 @@
|
|||
"psr/log": {
|
||||
"version": "1.1.3"
|
||||
},
|
||||
"ramsey/collection": {
|
||||
"version": "1.1.1"
|
||||
},
|
||||
"ramsey/uuid": {
|
||||
"version": "4.1.1"
|
||||
},
|
||||
"ramsey/uuid-doctrine": {
|
||||
"version": "1.3",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes-contrib",
|
||||
"branch": "master",
|
||||
"version": "1.3",
|
||||
"ref": "471aed0fbf5620b8d7f92b7a5ebbbf6c0945c27a"
|
||||
},
|
||||
"files": [
|
||||
"config/packages/ramsey_uuid_doctrine.yaml"
|
||||
]
|
||||
},
|
||||
"symfony/cache": {
|
||||
"version": "v5.2.0-rc1"
|
||||
},
|
||||
|
@ -44,6 +159,9 @@
|
|||
"symfony/deprecation-contracts": {
|
||||
"version": "v2.2.0"
|
||||
},
|
||||
"symfony/doctrine-bridge": {
|
||||
"version": "v5.2.0-rc1"
|
||||
},
|
||||
"symfony/dotenv": {
|
||||
"version": "v5.2.0-rc1"
|
||||
},
|
||||
|
@ -103,6 +221,18 @@
|
|||
"symfony/http-kernel": {
|
||||
"version": "v5.2.0-rc1"
|
||||
},
|
||||
"symfony/maker-bundle": {
|
||||
"version": "1.0",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes",
|
||||
"branch": "master",
|
||||
"version": "1.0",
|
||||
"ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f"
|
||||
}
|
||||
},
|
||||
"symfony/orm-pack": {
|
||||
"version": "v2.0.0"
|
||||
},
|
||||
"symfony/polyfill-intl-grapheme": {
|
||||
"version": "v1.20.0"
|
||||
},
|
||||
|
@ -135,6 +265,9 @@
|
|||
"symfony/service-contracts": {
|
||||
"version": "v2.2.0"
|
||||
},
|
||||
"symfony/stopwatch": {
|
||||
"version": "v5.2.0-rc1"
|
||||
},
|
||||
"symfony/string": {
|
||||
"version": "v5.2.0-rc1"
|
||||
},
|
||||
|
@ -146,5 +279,8 @@
|
|||
},
|
||||
"symfony/yaml": {
|
||||
"version": "v5.2.0-rc1"
|
||||
},
|
||||
"webimpress/safe-writer": {
|
||||
"version": "2.1.0"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue