Every address in Sylius is represented by the Address model. It has a few important fields:

  • firstName
  • lastName
  • phoneNumber
  • company
  • countryCode
  • provinceCode
  • street
  • city
  • postcode


The Address has a relation to a Customer - which is really useful during the Checkout addressing step.

How to create an Address programmatically?

In order to create a new address, use a factory. Then complete your address with required data.

/** @var AddressInterface $address */
$address = $this->container->get('sylius.factory.address')->createNew();

$address->setCompany('Ministry of Magic');
$address->setCity('Little Whinging');
$address->setStreet('4 Privet Drive');

// and finally having the address you can assign it to any Order