====== Symfony ======
===== Initialization =====
symfony new projectname [--webapp] # create new project
cd projectname
composer req templates # install twig
composer req debug # install debug tools
composer req symfony/asset # asset() function (TBC if useful)
composer req symfony/orm-pack
composer req --dev symfony/maker-bundle # some tools to generate assets
===== Configuration =====
Create ''docker-compose.yml'' to contain ''mariadb'' and (optionally) adminer and set db connect string in environment file ''.env'' (see below)
# start docker db
docker compose up -d
# ensure db exists
./bin/console doctrine:database:create --if-not-exists
===== Code Generation =====
# create entity
./bin/console make:entity User
# ...
# crea db stuff
./bin/console make:migration
./bin/console doctrine:migrations:migrate
# now the crud part
# add a couple of make:crud dependencies
composer req form validator security-csrf annotations
# get rid of deprecated stuff (does not work...)
# composer remove sensio/framework-extra-bundle
# now create controller etc.
./bin/console make:crud User
# start up server
symfony server:start -d
# and go to /user/ in browser
later...
composer recipes # update all recipes
docker-compose.yml
version: '3'
services:
db:
image: mariadb:latest
volumes:
- ./data/mariadb:/var/lib/mysql
ports:
- 3306:3306
restart: unless-stopped
environment:
MARIADB_ROOT_PASSWORD: adminpwd
MARIADB_DATABASE: sft
MARIADB_USER: sft
MARIADB_PASSWORD: sft
adminer:
image: adminer
restart: always
ports:
- 8080:8080
.env:
DATABASE_URL="mysql://sft:sft@127.0.0.1:3306/sft?serverVersion=mariadb-10.11.2"
--- //[[jrt@gmx.de|Jonas Rathert]] 2023/03/23 10:48//