logo for housekeeping

Start Swimming for
SilverStripe four

Namespaces and you

Tena Koutou

Who is this guy?

A web developer. First met Silverstripe in 2008 (v2.2), haven't really looked back much since.

SilverStripe Ltd.

In 2016 I joined the mothership.

Upgrading things has been my job for the past 8 months.

This talk

  • SS4 overview
  • Technicalities
  • Gotchas
  • ???
  • Profit.
  • Namespaces
  • Namespaces
  • Namespaces
  • ???
  • Namespaces.

SS4

What's new?

  • Speed
  • Recipes
  • Abstracted Assets
  • Versioning Versions via Versioned

Why upgrade?

  • New project
  • New skills
  • Elemental
  • Solve problems faster

When to upgrade?

Now.

Technicalities

Everything's the same

…But way, way different.

PSR

1 2 4 3 16

  • Coding Standard
  • Coding Style
  • Autoloading
  • HugsLogging
  • Simple Cache

Re-file

vendor, resources, public, app

Learn to love the vendor-expose

Resource lookups

New exposure, new format

vendor/module: path/file.ext

Upped their game

  • Emailing
  • File Storing

Booting

Middleware

Socks. Because they're the middleware of boots.

Object is gone Traits are in

Namespaces

Upgrading

What does it take?

Ensure your environment.

Update composer.json and support files

Shape up your code.

(optional)

I recommend namespacing it.

use your PHP dependencies

Class strings UsedClassName::class

Namespaces, NAMESPACES EVERYWHERE

Expose static assets

A namespacing of sorts

Requirements::css('silverstripe/cms: client/dist/styles/bundle.css');
    "extra": {
        "expose": [
            "client/dist",
            "client/lang"
        ]
    },

Alter your template files to match Namespaces

Update your configuration .yml

With Namespaces.

A lot of work?

I'm glad you noticed.

silverstripe/upgrader

Get it.

composer global require silverstripe/upgrader $VERSION

Environements

Convert _ss_environment.php to .env

upgrade-code environment

Update your composer dependencies

upgrade-code recompose

Namespaces

Generates an .upgrade.yml

upgrade-code add-namespace

Updates

and updates all references in your code

upgrade-code upgrade

Inspects

Identifying potential problems for you

upgrade-code inspect

Re-root

Helps you migrate to public/

upgrade-code webroot

Organise

Move project from mysite/ to app/

upgrade-code reorganise

Sounds too good to be true!

Well… Every software has it's trials.

Tip

Composer

  • Define fork repositories
  • Require development branches
  • Inline alias to satisfy recipies
"repositories": [
	{
		"type": "vcs",
		"url": "/path/to/fork-repo.git"
	}
],
"requirements": {
	"us/module": "dev-update-compatiblity as 4.1.1"
}

Last slide

Thanks.

Questions?