Skip to content

itk-dev/symfony-4-skeleton

Repository files navigation

Symfony 4 skeleton

This is a skeleton for a Symfony 4 project.

--- ✂ --------------------------------------------------------------------------

Skeleton installation (delete this section when done)

composer create-project itk-dev/symfony-4-skeleton my-itk-dev-project

Post skeleton installation

  • Edit .env and define the COMPOSE_PROJECT_NAME variable.
  • Edit $header in .php_cs.dist.
  • Edit README.md (Remove optional sections and describe your actual project).

Suggested packages

Doctrine:

composer require symfony/orm-pack
composer require --dev symfony/maker-bundle

Set DATABASE_URL in .env.dev:

DATABASE_URL=mysql://db:db@mariadb:3306/db

EasyAdminBundle:

composer require admin

EasyAdmin Extension:

composer require alterphp/easyadmin-extension-bundle

API Platform:

composer require api

Encore

composer require encore

Add tools for linting assets:

yarn add --dev eslint eslint-config-standard eslint-plugin-import eslint-plugin-node eslint-plugin-promise eslint-plugin-standard
yarn add --dev stylelint stylelint-config-recommended-scss stylelint-scss

Add these lines to scripts in package.json:

        "check-coding-standards/stylelint": "stylelint --config=.stylelintrc.js 'assets/**/*.scss'",
        "check-coding-standards/scss": "yarn run check-coding-standards/stylelint",
        "check-coding-standards/eslint": "eslint --config .eslintrc.js 'assets/**/*.js'",
        "check-coding-standards/js": "yarn run check-coding-standards/eslint",
        "check-coding-standards": "yarn run check-coding-standards/scss; yarn run check-coding-standards/js",
        "apply-coding-standards/stylelint": "stylelint --config=.stylelintrc.js 'assets/**/*.scss' --fix",
        "apply-coding-standards/scss": "yarn run apply-coding-standards/stylelint",
        "apply-coding-standards/eslint": "eslint --config .eslintrc.js 'assets/**/*.js' --fix",
        "apply-coding-standards/js": "yarn run apply-coding-standards/eslint",
        "apply-coding-standards": "yarn run apply-coding-standards/scss; yarn run apply-coding-standards/js"

See also:

--- ✂ --------------------------------------------------------------------------

Starting the show

docker-compose pull
docker-compose up -d

Open the site in your default browser:

open http://$(docker-compose port nginx 80)

Coding standards

Check Symfony coding standards using PHP Coding Standards Fixer and PHP_CodeSniffer:

composer check-coding-standards

Apply Symfony coding standards:

composer apply-coding-standards

Twig (experimental)

Check Twig templates using Twigcs:

composer check-coding-standards/twigcs

--- ✂ --- (remove this section if not using encore) ----------------------------

Assets (SCSS and JavaScript)

Check coding standards in all assets:

yarn check-coding-standards

Check coding standards in SCSS files:

yarn check-coding-standards/scss

Check coding standards in JavaScript files:

yarn check-coding-standards/js

Apply coding standards to all assets:

yarn apply-coding-standards

Apply coding standards to SCSS files:

yarn apply-coding-standards/scss

Apply coding standards to JavaScript files:

yarn apply-coding-standards/js

--- ✂ --------------------------------------------------------------------------