Skip to content

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

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

Full Stack Website Project

composer create-project symfony/website-skeleton .

API / Microserver or Console Application

composer create-project symfony/skeleton .

Initial Commit and Push

First update gitignore

echo '.idea' >> .gitignore
echo 'bin' >> .gitignore
echo '!bin/console' >> .gitignore

Then make initial commit

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:

  "config": {
        "preferred-install": {
            "edmondscommerce/*": "source",
            "*": "dist"
        },
        "sort-packages": true,
        "bin-dir": "bin"
    },

Setting PHP Version

php --version

Then update composer.json accordingly:

    "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

composer require edmondscommerce/typesafe-functions

Maker Bundle

Used to generate code

composer require symfony/maker-bundle --dev

PHPStan Symfony

Extend PHPStan for Symfony

composer require --dev phpstan/phpstan-symfony

Monolog

You are certainly going to require logging for any sane project

composer require symfony/monolog-bundle