Bootstrapping New Symfony Project

Once we have created our repo, we need to do the initial setup work to start a new Symfony project.

To bootstrap the project, run one of teh following composer commands:

Make sure composer is not aliased

symfony does not like it when composer is aliased Check your ~/.bashrc file for a composer alias and remove it if present (you will need to start a new session after you remove the alias)

Create Project Folder

1
2
3
4
mkdir <repo-folder>
cd <repo-folder>
# if you previously cloned, we need to remove that
rm -rf .git

Full Stack Website Project

1
composer create-project symfony/website-skeleton .

API / Microserver or Console Application

1
composer create-project symfony/skeleton .

Initial Commit and Push

First update gitignore

1
2
3
echo '.idea' >> .gitignore
echo 'bin' >> .gitignore
echo '!bin/console' >> .gitignore

Then make initial commit

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
git init

#add remotes
git remote add origin gitBare:~/repos/<clientname>/<reponame>
git remote add bitbucket git@bitbucket.org:<teamname>/<reponame>.git

#add master branch
echo '[branch "master"]
    remote = origin
    merge = refs/heads/master
' >> .git/config

#initial commit
git add -A
git commit -am 'initial commit'

#push
git push -u origin master

This should have triggered the post receive hook to push into bitbucket, you should go and check bitbucket at this stage

Updating Composer Configurations:

Set EdmondsCommerce Packages to be installed as git repos:

1
2
3
4
5
6
7
8
  "config": {
        "preferred-install": {
            "edmondscommerce/*": "source",
            "*": "dist"
        },
        "sort-packages": true,
        "bin-dir": "bin"
    },

Setting PHP Version

1
php --version

Then update composer.json accordingly:

1
2
    "require": {
        "php": "^7.2.12",

Core Dependency Install

The following composer dependencies should always be installed:

Typesafe Functions

A centralised solution to passing stan issues by wrapping core functions and objects with typesafe versions

1
composer require edmondscommerce/typesafe-functions

Maker Bundle

Used to generate code

1
composer require symfony/maker-bundle --dev

PHPStan Symfony

Extend PHPStan for Symfony

1
composer require --dev phpstan/phpstan-symfony

Monolog

You are certainly going to require logging for any sane project

1
composer require symfony/monolog-bundle