Starter for creating Symfony 4/5/6 sites at XM Media

dev-master 2024-05-10 14:30 UTC


Used to create new projects using Symfony 6 at XM Media.

Setting Up a New Site

  1. Create a new project:
    composer create-project xm/starter_symfony_4 project-name --stability=dev --no-install --remove-vcs
  2. Add .env.local – copy .env and update.
  3. Update composer.json: name, license (likely private) and description
  4. Update package.json: name, version, git.url, license (probably delete), private
  5. Update the port in vite.config.js (server.port and server.origin)
  6. Remove or update the LICENSE file.
  7. Composer install & update: composer install && composer update (or without memory limit: php -d memory_limit=-1 /usr/local/bin/composer update)
  8. Run yarn && yarn upgrade.
  9. Run yarn dev or yarn build (for production) to compile JS & CSS files.
  10. Give executable perms to bin dir: chmod u+x bin/*
  11. Add nitro site: nitro add (updating .env won't do anything).
  12. Create database with event streams & projections tables from db_create.sql using nitro db import.
    • If possible, set database collation to utf8mb4_bin: ALTER DATABASE <database_name> CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
  13. Create the required event streams with the command: bin/console event-store:event-stream:create user && bin/console event-store:event-stream:create auth (or if using lando: lando console event-store:event-stream:create user && lando console event-store:event-stream:create auth).
  14. Run all projections once: bin/console event-store:projection:run user_projection -o (or if using lando: lando console event-store:projection:run user_projection -o).
  15. Create a user bin/console app:user:add (select role ROLE_SUPER_ADMIN).
  16. Find and make changes near @todo-symfony comments throughout the site.
  17. Delete starter files: README.md (or update) and TEMPLATES.md.
  18. Optional: Run composer test – will install PHPUnit & run PHP tests
  19. Create new favicons: realfavicongenerator.net
  20. Copy (use "Push to another server") or recreate the templates in Postmark. The templates are referenced by the aliases.
  21. Optional: Run bin/console app:graphql:dump-schema <username> to update the GraphQL schema file where username is the email of an admin user.
  22. Optional: Rename the project in PhpStorm.

Dev site can be accessed at https://[domain]/

System Requirements

  • PHP 8.2
  • MySQL 5.7+
  • Node 18
  • Yarn v3


  • Production JS/CSS build: yarn build
  • Dev JS/CSS build: yarn dev
  • Preview production JS/CSS build: yarn preview
  • JS Tests (Jest): yarn test:unit
  • Linting:
    • JS (ESLint): yarn lint:js or yarn lint:js:fix
    • CSS: yarn lint:css or yarn lint:css:fix
  • PHP Tests (PhpUnit):
    • composer test
    • no memory limit php -d memory_limit=-1 bin/simple-phpunit
    • with coverage (HTML) composer test:coverage
  • PHP CS: (must be installed first)
    • Dry run: composer cs
    • Fix: composer cs:fix
  • PHP Static Analysis (PHPStan): composer static
  • Projections:
    • Show all commands: bin/console event-store:projection
    • Run once: bin/console event-store:projection:run user_projection -o
  • Makers (PHP):
    • Make aggregate root/model: bin/console make:model
    • Make projection: bin/console make:projection

Incorporated Libraries & Tools