Skip to content

Symfony + Doctrine - Playground + Experiments.

Notifications You must be signed in to change notification settings

TheRemoteCoder/Symfony-Doctrine-Playground

Repository files navigation

Symfony + Doctrine Playground





Intro

As of 2021/03: All Symfony setups are empty and unused, except for :

  • /website/ - Basic config, dev stack, secrets
  • /udemy-bikeshop/ - Udemy course data




Config

Generic Symfony config.

ENV

Set in .env file:

DATABASE_URL="mysql://root:@127.0.0.1:3306/example_store"




Setup

Generic Symfony setup.

Server certificate

  • MacOS: Switch to admin user and install there, than switch back
    • Root user might be disabled and cannot be used
    • Sudo user switching did not work in own test

Dependencies

  • composer install
  • npm i

Build encore

ENV file config

  • Set user and password in .env under DATABASE_URL
  • Make sure SQL user has correct authentication method for SQL/PHP version
    • Here: Needs the older 'Standard' auth (not SHA2)

Create + Fill database

Optional, if files exist – Create DB + tables with content.

Create

  • php bin/console make:migration
  • php bin/console doctrine:database:create

Migrate

  • php bin/console doctrine:migrations:migrate




Debugging

Exemplaric showcases.

# Show Services + Use cases
php bin/console debug:autowiring

# Show Symfony, Kernel, PHP versions + other details
php bin/console about

# Security config
php bin/console debug:config security

# Show events
php bin/console debug:event-dispatcher kernel.controller




Maintenance

Via Symfony CLI (install separately) - Check package security (similar to NPM).

symfony check:security




Doctrine

php bin/console doctrine:query:sql "SHOW VARIABLES"




Issues

Doctrine

On error: The metadata storage is not up to date ...

# - Create migration, migrate?
# - Sync metadata (did not work during test)
# - change .env file MySQL to MariaDB version
php bin/console doctrine:migrations:generate
php bin/console doctrine:migrations:migrate
php bin/console doctrine:migrations:sync-metadata-storage