Used to create new projects using Symfony 4 at XM Media.
- Download a copy of this repo (probably as a ZIP).
- Remove or update the
LICENSE
file. - Install Composer locally.
- Update
composer.json
:name
,license
(likelyprivate
) anddescription
- Update
package.json
:name
,version
,git.url
,license
,private
,script.dev-server
- Composer install & update (locally):
composer install && composer update
(or without memory limit:php -d memory_limit=-1 /usr/local/bin/composer update
) - Run
yarn && yarn upgrade
locally. - Find and make changes near
@todo-symfony
comments throughout the site. - Setup server:
- Upload the files (exclude files that are OS dependent like
node_modules
&.env
or that are only for editing like.idea
and a lot of what's in.gitignore
). - Install Composer
- Install PHP packages/vendors:
php composer.phar install
- Update
.env
. - Install NVM: https://github.com/creationix/nvm#install-script
- Run
. ./node_setup.sh
(this will setup node & install the JS packages). - Run
yarn dev
oryarn build
(for production) to compile JS & CSS files. - Create event streams & projections tables from: https://github.com/prooph/pdo-event-store/tree/master/scripts/mysql
- Create one or more event streams with the command
bin/console event-store:event-stream:create user && bin/console event-store:event-stream:create auth
(and if using enquiry:bin/console event-store:event-stream:create enquiry
) - Run all projections once:
bin/console event-store:projection:run user_projection -o
bin/console event-store:projection:run user_token_projection -o
bin/console event-store:projection:run enquiry_projection -o
- Create a user
bin/console app:user:add
& run user projection:bin/console event-store:projection:run user_projection -o
- Copy or recreate the templates in Postmark & update the template IDs (see
@todo-symfony
). - Setup supervisord:
- Write supervisord config:
bin/console app:supervisor:write-config
- Add site supervisord config to main config, for example
files = /etc/supervisord/*.conf /home/user/supervisord.conf
(as root) - Tell supervisord to read the config:
supervisorctl reread && supervisorctl update
(as root) - Ensure programs are running:
supervisorctl status
- Write supervisord config:
- Setup mail spool: add cron task similar to:
*/15 * * * * cd /home/user/example.com/current && bin/console swiftmailer:spool:send --message-limit=10 --time-limit=45 >> var/log/mailer.log 2>&1
(this only sends error emails, runs every 15 minutes) - Add logrotate cron:
30 4 * * 1 cd /home/user/example.com/current && logrotate app/config/packages/logrotate.conf --state var/logrotate-state
(runs Mondays at 04:30 UTC)
- Upload the files (exclude files that are OS dependent like
- Delete starter files:
README.md
(or update) andTEMPLATES.md
. - Run
composer test
– will install PHPUnit & run PHP tests - Create new favicons: realfavicongenerator.net
Dev site can be accessed at https://[domain]/
- PHP 7.3+
- MySQL 5.7+
- Yarn
- Production JS/CSS build:
yarn build
- Dev JS/CSS build:
yarn dev
- Dev JS/CSS watch:
yarn watch
(files will not be versioned) - Dev JS/CSS HMR server:
yarn dev-server
(see below) - JS Tests (Jest):
yarn test:unit
- E2E Tests (Cypress):
yarn test:e2e
- Linting:
- JS (ESLint):
yarn lint:js
oryarn lint:js:fix
- CSS:
yarn lint:css
oryarn lint:css:fix
- JS (ESLint):
- 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
- Dry run:
- PHP Static Analysis (PHPStan):
composer static
- Projections:
- All commands:
bin/console event-store:projection
- Run once:
bin/console event-store:projection:run user_projection -o
- All commands:
The following is needed in the Apache VirtualHost for the Webpack Dev Server/HMR to work:
ProxyPassMatch ^(\/dev-server\/.+$)|(sockjs-node) http://localhost:<port>
ProxyPassReverse / http://localhost:<port>
You'll probably want to customize the port number in the Apache ProxyPass config
and in package.json
(script.dev-server
) to be unique to each project if
running multiple sites on one server.
- Frontend – full list of dependencies can be found in package.json
- Vue – frontend framework
- Vue Router – routing package for frontend
- Vuex – helps to manage state
- Vue Devtools – makes debugging in the browser easier
- Vue Templates – the syntax for .vue files
- Vue Test Utils – to help testing Vue components
- Vue CLI – to manage & run the frontend compilation & testing
- GraphQL – the communication (query) language for the API
- Apollo Client through Vue Apollo – frontend GraphQL
- SASS – CSS preprocessor (uses node-sass)
- Webpack – compiles JS & CSS
- Babel – transforms JS to work in all browsers
- Webpack Encore – connects the frontend and backend and makes Webpack configuration simpler
- PostCSS – transforms CSS
- Autoprefixer – for adding browser prefixes
- Purge CSS – removes unused CSS during the deployment process (not run in dev)
- SVGO – optimizes SVG files
- Bundle Analyzer – displays sizes/stats on the JS bundle size
- Tailwind – utility first styling framework
- Jest – JS unit testing
- Cypress – end-to-end (e2e) testing
- Lodash – helper functions for JS
- date-fns – helper functions for Dates in JS
- PortalVue – helps to manage things like modals
- Vue-JS-Modal – for modals
- Workbox – helps with configuration of service worker/PWA
- Faker.js – for generating fake data in tests
- ESLint – checks JS for conventions & errors
- Stylelint – checks CSS for conventions & errors
- Vue – frontend framework
- Backend – full list of dependencies can be found in composer.json
- Symfony – backend framework
- GraphQLBundle – provides GraphQL in PHP using graphql-php
- GraphQiL is available at
/graphiql
(on dev only)
- GraphQiL is available at
- Twig – server side templating language (limited use)
- Prooph PDO Event Store & Bridge/Bundle – for doing Event Sourcing
- Doctrine – for reading from read models
- PhpUnit – for running PHP tests
- PHP CS – PHP coding standards analyzer & fixer
- PHPStan – static analysis of PHP
- Postmark – for sending email, contains email templates (currently setup under XM Media's account)
- Cloudflare – DNS & CDN
- GitLab – deployment
- Dev Tools
- Vue Devtools
- Apollo Devtools
- GraphQiL is available at
/graphiql