make init-dev
To check:
- if entities has changed, a new migration should be created
@see https://datatracker.ietf.org/doc/html/rfc7807 via symfony/serializer-pack and https://symfony.com/doc/current/controller/error_pages.html
For loggin: Monolog\Formatter\JsonFormatter (this is WIP)
The database access is configured directly via the environment variable "DATABASE_URL", In dev:
- In development
During development it is safe to assume:
composer run console -- doctrine:schema:update --force
working
- In production
To deploy new structures in production (IE mapping update):
- Generate a migration
composer run console -- doctrine:migrations:diff
- Apply the migration in production
composer run console -- doctrine:migrations:migrate
- Entity
declare(strict_types=1);
namespace App\Modules\Dummy\Entity;
use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;
#[ORM\Entity()]
class Dummy implements JsonSerializable {
#[ORM\Id()]
#[ORM\GeneratedValue(strategy: "CUSTOM")]
#[ORM\Column(type: "uuid", unique: true)]
#[ORM\CustomIdGenerator(class: \Ramsey\Uuid\Doctrine\UuidGenerator::class)]
private $id;
public function jsonSerialize(): array {
return [
"id" => $this->id
];
}
}
- Repository (here the name of the entity is event, and the domain name is event too)
<?php
declare(strict_types=1);
namespace App\Modules\Dummy\Repository;
use App\Modules\Dummy\Entity\Dummy as EntityDummy;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
class Dummy
{
private EntityManagerInterface $entityManager;
/**
* @var EntityRepository<EntityDummy>
*/
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{
$this->entityManager = $entityManager;
$this->repository = $this->entityManager->getRepository(EntityDummy::class);
}
/**
* @return iterable<EntityDummy>
*/
public function findAll(): iterable
{
return $this->repository->findAll();
}
}
docker run --rm --volume=`pwd`/app:/usr/src/app/:rw thecodingmachine/php:8.0-v4-apache -- bash -c "cd '/usr/src/app/' && composer create-project symfony/skeleton backend"
docker run --rm --volume=`pwd`/app/backend:/usr/src/app/:rw thecodingmachine/php:8.0-v4-apache -- bash -c "cd '/usr/src/app/' && composer require mypackage"
docker run --rm --volume=`pwd`/app/backend:/usr/src/app/:rw thecodingmachine/php:8.0-v4-apache -- bash -c "cd '/usr/src/app/' && php bin/console debug:config monolog"
https://symfony.com/doc/current/configuration.html#configuration-environments
connect to the container then run
php bin/console doctrine:sc:update --dump-sql