xm/starter_symfony_4

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

dev-master 2025-08-19 23:14 UTC

This package is auto-updated.

Last update: 2025-08-19 23:19:12 UTC


README

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

Dev: https://symfonystarter.lndo.site @todo-symfony
Staging: @todo-symfony
Production: @todo-symfony

Setting Up a New Site

Note: Make sure your git configuration is set to use the correct line endings: git config --global core.autocrlf input && git config --global core.eol lf

  1. Create a new project:
    composer create-project xm/starter_symfony_4 project-name --stability=dev --no-install --remove-vcs
    To run this, Composer needs to be installed globally. If you don't have Composer installed, follow the instructions at getcomposer.org/download.
  2. Copy .env.local-default to .env.local and update the values where there are @todo-symfony comments.
  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: lando composer install && lando composer update (or remove lando to run without Lando or without memory limit: php -d memory_limit=-1 /usr/local/bin/composer update)
  8. Run yarn && yarn up -R "**".
  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/* (helpful, but optional)
  11. Run/Start Lando site: lando start
  12. Create database with event streams & projections tables from db_create.sql using lando db-import db_create_sql.
    • 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 && bin/console event-store:projection:run auth_projection -o (or if using lando: lando console event-store:projection:run user_projection -o && lando console event-store:projection:run auth_projection -o).
  15. Create a user bin/console app:user:add (select role ROLE_SUPER_ADMIN) (or if using lando: lando console app:user:add).
  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.
  23. Optional: Run npx @sentry/wizard@latest -i sourcemaps to configure Sentry to upload source maps for the frontend.

Local dev site can be accessed at: https://[domain]/

Setting Up Starter

  1. Checkout the repo.
  2. Copy .env.local-default to .env.local and update the values where there are @todo-symfony comments.
  3. Run/Start Lando site: lando start
  4. Composer install: lando composer install or composer install to run without Lando.
  5. Ensure correct node version: nvm use
  6. Run yarn.
  7. Run yarn dev or yarn build (for production) to compile JS & CSS files.
  8. Give executable perms to bin dir: chmod u+x bin/* (helpful, but optional)
  9. Create database with event streams & projections tables from db_create.sql using lando db-import db_create_sql.
    • If possible, set database collation to utf8mb4_bin: ALTER DATABASE <database_name> CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; This can be done through PhpMyAdmin (link provided by lando start command above or lando info)
  10. 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).
  11. Run all projections once: bin/console event-store:projection:run user_projection -o && bin/console event-store:projection:run auth_projection -o (or if using lando: lando console event-store:projection:run user_projection -o && lando console event-store:projection:run auth_projection -o).
  12. Create a user bin/console app:user:add (select role ROLE_SUPER_ADMIN) (or if using Lando: lando console app:user:add).
  13. Optional: Run composer test – will install PHPUnit & run PHP tests – or lando composer test if using Lando.
  14. Run bin/check to run all code tests/checks.

**Local dev site can be accessed at: https://symfonystarter.lndo.site

System Requirements

Server

  • PHP 8.4
  • MySQL 8.0

Locally for Development

Commands

  • Check all code: bin/check
  • Production JS/CSS build: yarn build
  • Dev JS/CSS build: yarn dev (recommended command: nvm use && yarn && 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
  • Install PHP packages: lando composer install or composer install
  • Install JS packages: yarn
  • PHP Tests (PhpUnit):
    • lando composer test or composer test
    • no memory limit php -d memory_limit=-1 bin/phpunit
    • with coverage (HTML) composer test:coverage
    • show deprecations composer test:deprecations
  • PHP CS: (must be installed first)
    • Dry run: lando composer cs or composer cs
    • Fix: lando composer cs:fix or composer cs:fix
  • PHP Static Analysis (PHPStan): lando composer static or 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
  • Upgrade JS packages: yarn up -R "**"
    • Upgrade a specific package: yarn up -R "package-name"
    • Upgrade major versions: yarn upgrade-interactive (ctrl+c to exit without changes)

Incorporated Libraries & Tools

Updating PHP version

  1. Change version in composer.json & add polyfill for new PHP version, ie, symfony/polyfill-php84.
  2. Update the PHP version in the following files:
    • .lando.yml
    • setup_dev.sh – 4 places
    • setup_prod.sh – 4 places
    • .gitlab-ci.yml – 2 places
  3. Run lando rebuild to rebuild the Lando container with the new PHP version.
  4. Run lando composer update or composer update to update the PHP dependencies.
  5. Run the checks nvm use && bin/check_full.
  6. Update version in README.md.