SlideShare a Scribd company logo
1 of 26
Download to read offline
Upgrading to SilverStripe 4
Projects, modules, tips and tricks
22 Feb 2017 • Robbie Averill
● PHP namespaces
● Bootstrap 4 in the CMS
● ReactJS
● Public API changes - lots of them
● Quirks! E.g. dotenv
● PSR-2 style guidelines
● Controller naming: Page_Controller -> PageController
● Config API is changing! Still to come...
SilverStripe 4 Changes
(That generally affect you: a developer)
SilverStripe Roadmap
● Modules: now!
● Projects: now/soon (beta)
When should I upgrade?
Run a quick upgradability check!
Disclaimer: It's a QUICK check!
gist.github.com/robbieaverill/cad0260414226645b404c45b2059fdf9
Projects: fork and fix!
Get involved with the open source community. It might
be a quick job, you might be surprised!
Suggested tools:
● Hub: hub.github.com
● silverstripe/upgrader:
github.com/silverstripe/silverstripe-upgrader
Composer
● List your forks as VCS repositories until merged
● Projects: "minimum-stability": "dev" and
"prefer-stable": true
● "extra": {
"branch-alias": {
"dev-master": "2.x-dev"
}
}
Modules: Get into it, now!
● The more SilverStripe 4 compatible a module is, the
more likely you and other developers will use it, and
recommend it for use to those you work for
● Upgrading a module will give you a much deeper
understanding of how it works, especially if you didn't
write it!
Namespacing and PSR-4
People asked, SilverStripe responded. Please welcome namespacing to the
stage!
With it comes PSR-4 compatible autoloading, which makes sense.
● Use "git mv" to configure your module for PSR-4
compatibility without losing history
● Add and implement namespaces with the upgrader
● Do these in separate commits/PRs from PSR-2 linting
Adding namespaces with upgrader
Implementing namespaces
Implementing PSR-4
Tip: don't forget to run composer validate!
The framework has switched to using dotenv for configuration. It's worth
mentioning now, because you won't be able to "build" without it.
File: .env
Hello dotenv, bye bye _ss_environment
In SilverStripe the suggested PHP style guideline to follow is
PSR-2 (which includes PSR-1).
This means spaces for indentation, brackets on new lines,
sensible spacing, etc.
You can automate most of the required changes using PHP
CodeSniffer and the PSR2 standard it ships with.
More info: php-fig.org/psr/psr-2
PHP style guidelines: PSR-1/2
● In 3.x: Page_Controller
● In 4.x: PageController
Don't forget to add this to the .upgrade.yml mapping!
Move the controller to its own file now - PSR-2 requires each
class to be on its own.
Naming controllers
In SilverStripe 3.x you can mostly put templates wherever
you feel like.
With 4.x things are stricter:
● Default: fully qualified template location matches class
namespace
● ->renderWith('TemplateName'): still looks in root
of "templates"
SilverStripe encourages the use of fully qualified template
locations where possible, even if you don't have to move
them when you upgrade!
Naming templates
DataObject table names
By default a namespaced DataObject will use a backslash in the table name,
matching the namespace. To replace this, or to provide backwards compatibility,
specify private static $table_name = 'MyTableName'; on your
DataObject.
BuildTask segments
BuildTasks will use a fully qualified class name (sanitised) for the segment. You
may see dev/tasks/Robbie-MeetupDemo-Task-DoesNothingTask. To
make this simpler, add private static $segment =
'DoesNothingTask'; to your task.
Small gotchas
● "ClassName" value remapping
When working with existing data (i.e. upgrade, not fresh install), if your
DataObject has a ClassName field, it will need to become fully qualified in
legacy date. Use YAML config - see the CMS module for an example.
● php-intl extension is now required
● Upgrader bugs:
Still in development too - it will occasionally replace things it shouldn't.
Doesn't update YAML configuration files (yet). This also applies to YAML
fixtures in unit test - they must be fully qualified!
More gotchas...
Handling files, or whatever
● Asset abstraction provides secure assets out of the
box as well as versioning and coupling with
campaigns
● The upload process changes
● The image manipulation public API has changed a
bit
● Take a look at the changelog
Mono-Logging!
SS_Log is still available, but it's deprecated - you shouldn't
and probably can't use it.
Instead, use Monolog (PSR-3 compatible) via the Injector:
More: github.com/Seldaek/monolog
Cascading themes!
As very cool feature - now you can have multiple themes
that inherit from each other! This includes looking up
resources by their base filename across any registered
theme.
Deprecation and removals
● All deprecation and removals are documented in the
4.0.0 changelog, which is kept up to date
● If your code complains, check for updates
● Some important backends have been updated or
replaced entirely: logging, config (shortly), localisation,
cache (soon)
Considerations
● Entwine being phased out in favour of ReactJS (CMS)
● Use Webpack or similar for bundling assets
● REST API modules replaced with core GraphQL
● RestfulService gone, use guzzlehttp/guzzle or similar
● Use the injector wherever you can
General tips
● Good unit test coverage to start with will help a lot
● Start namespacing early if you can (SS3 can handle it, to
an extent)
● Use the upgrader tool
● Bump your branch alias
● Release alpha tags for your upgraded code
Useful links
● docs.silverstripe.org/en/4/changelogs/4.0.0
● github.com/silverstripe/silverstripe-upgrader
● github.com/robbieaverill/meetup-demo
● hub.github.com
● gist.github.com/robbieaverill/cad0260414226645b404c
45b2059fdf9
Thank you!
Twitter: @robbieaverill
Email: robbie@silverstripe.com
22nd Feb 2017 • Robbie Averill

More Related Content

What's hot

What's hot (20)

An introduction to Rails 3
An introduction to Rails 3An introduction to Rails 3
An introduction to Rails 3
 
Flyway
FlywayFlyway
Flyway
 
Ruby, the language of devops
Ruby, the language of devopsRuby, the language of devops
Ruby, the language of devops
 
IDLs
IDLsIDLs
IDLs
 
Reflection in Pharo5
Reflection in Pharo5Reflection in Pharo5
Reflection in Pharo5
 
External Master Data in Alfresco: Integrating and Keeping Metadata Consistent...
External Master Data in Alfresco: Integrating and Keeping Metadata Consistent...External Master Data in Alfresco: Integrating and Keeping Metadata Consistent...
External Master Data in Alfresco: Integrating and Keeping Metadata Consistent...
 
Flywaydb
FlywaydbFlywaydb
Flywaydb
 
There's more to Ratpack than non-blocking
There's more to Ratpack than non-blockingThere's more to Ratpack than non-blocking
There's more to Ratpack than non-blocking
 
Virtualizing Development
Virtualizing DevelopmentVirtualizing Development
Virtualizing Development
 
Mini Training Flyway
Mini Training FlywayMini Training Flyway
Mini Training Flyway
 
JCR - Java Content Repositories
JCR - Java Content RepositoriesJCR - Java Content Repositories
JCR - Java Content Repositories
 
Perl Continous Integration
Perl Continous IntegrationPerl Continous Integration
Perl Continous Integration
 
App engine ja night 9 beertalk2
App engine ja night 9 beertalk2App engine ja night 9 beertalk2
App engine ja night 9 beertalk2
 
Scala adoption by enterprises
Scala adoption by enterprisesScala adoption by enterprises
Scala adoption by enterprises
 
Apache Jackrabbit
Apache JackrabbitApache Jackrabbit
Apache Jackrabbit
 
Backing Data Silo Atack: Alfresco sharding, SOLR for non-flat objects
Backing Data Silo Atack: Alfresco sharding, SOLR for non-flat objectsBacking Data Silo Atack: Alfresco sharding, SOLR for non-flat objects
Backing Data Silo Atack: Alfresco sharding, SOLR for non-flat objects
 
javerosmx-2015-marzo-groovy-java8-comparison
javerosmx-2015-marzo-groovy-java8-comparisonjaverosmx-2015-marzo-groovy-java8-comparison
javerosmx-2015-marzo-groovy-java8-comparison
 
Migration from joc to jpc or choral
Migration from joc to jpc or choralMigration from joc to jpc or choral
Migration from joc to jpc or choral
 
Database migrations with Flyway and Liquibase
Database migrations with Flyway and LiquibaseDatabase migrations with Flyway and Liquibase
Database migrations with Flyway and Liquibase
 
Configuration Management - Finding the tool to fit your needs
Configuration Management - Finding the tool to fit your needsConfiguration Management - Finding the tool to fit your needs
Configuration Management - Finding the tool to fit your needs
 

Similar to Wellington meetup SilverStripe 4 upgrading presentation (Feb 2017)

Selena Deckelmann - Sane Schema Management with Alembic and SQLAlchemy @ Pos...
Selena Deckelmann - Sane Schema Management with  Alembic and SQLAlchemy @ Pos...Selena Deckelmann - Sane Schema Management with  Alembic and SQLAlchemy @ Pos...
Selena Deckelmann - Sane Schema Management with Alembic and SQLAlchemy @ Pos...
PostgresOpen
 

Similar to Wellington meetup SilverStripe 4 upgrading presentation (Feb 2017) (20)

Composer Helpdesk
Composer HelpdeskComposer Helpdesk
Composer Helpdesk
 
[HKDUG] #20161210 - BarCamp Hong Kong 2016 - What's News in PHP?
[HKDUG] #20161210 - BarCamp Hong Kong 2016 - What's News in PHP?[HKDUG] #20161210 - BarCamp Hong Kong 2016 - What's News in PHP?
[HKDUG] #20161210 - BarCamp Hong Kong 2016 - What's News in PHP?
 
APEX Application Lifecycle and Deployment 20220714.pdf
APEX Application Lifecycle and Deployment 20220714.pdfAPEX Application Lifecycle and Deployment 20220714.pdf
APEX Application Lifecycle and Deployment 20220714.pdf
 
12 Introduction to Rails
12 Introduction to Rails12 Introduction to Rails
12 Introduction to Rails
 
Migraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sitesMigraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sites
 
The Power Of Schematron Quick Fixes - XML Prague 2019
The Power Of Schematron Quick Fixes - XML Prague 2019The Power Of Schematron Quick Fixes - XML Prague 2019
The Power Of Schematron Quick Fixes - XML Prague 2019
 
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
 
Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7
 
Essential Tools for Modern PHP
Essential Tools for Modern PHPEssential Tools for Modern PHP
Essential Tools for Modern PHP
 
01 - Git vs SVN
01 - Git vs SVN01 - Git vs SVN
01 - Git vs SVN
 
Performant Django - Ara Anjargolian
Performant Django - Ara AnjargolianPerformant Django - Ara Anjargolian
Performant Django - Ara Anjargolian
 
Kubernetes - State of the Union (Q1-2016)
Kubernetes - State of the Union (Q1-2016)Kubernetes - State of the Union (Q1-2016)
Kubernetes - State of the Union (Q1-2016)
 
Doctrine Project
Doctrine ProjectDoctrine Project
Doctrine Project
 
My "Perfect" Toolchain Setup for Grails Projects
My "Perfect" Toolchain Setup for Grails ProjectsMy "Perfect" Toolchain Setup for Grails Projects
My "Perfect" Toolchain Setup for Grails Projects
 
Scaling symfony apps
Scaling symfony appsScaling symfony apps
Scaling symfony apps
 
PHP Development Tools
PHP  Development ToolsPHP  Development Tools
PHP Development Tools
 
Rapidly prototyping web applications using BackPress
Rapidly prototyping web applications using BackPressRapidly prototyping web applications using BackPress
Rapidly prototyping web applications using BackPress
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
 
They why behind php frameworks
They why behind php frameworksThey why behind php frameworks
They why behind php frameworks
 
Selena Deckelmann - Sane Schema Management with Alembic and SQLAlchemy @ Pos...
Selena Deckelmann - Sane Schema Management with  Alembic and SQLAlchemy @ Pos...Selena Deckelmann - Sane Schema Management with  Alembic and SQLAlchemy @ Pos...
Selena Deckelmann - Sane Schema Management with Alembic and SQLAlchemy @ Pos...
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 

Wellington meetup SilverStripe 4 upgrading presentation (Feb 2017)

  • 1. Upgrading to SilverStripe 4 Projects, modules, tips and tricks 22 Feb 2017 • Robbie Averill
  • 2. ● PHP namespaces ● Bootstrap 4 in the CMS ● ReactJS ● Public API changes - lots of them ● Quirks! E.g. dotenv ● PSR-2 style guidelines ● Controller naming: Page_Controller -> PageController ● Config API is changing! Still to come... SilverStripe 4 Changes (That generally affect you: a developer)
  • 4. ● Modules: now! ● Projects: now/soon (beta) When should I upgrade?
  • 5. Run a quick upgradability check! Disclaimer: It's a QUICK check! gist.github.com/robbieaverill/cad0260414226645b404c45b2059fdf9
  • 6. Projects: fork and fix! Get involved with the open source community. It might be a quick job, you might be surprised! Suggested tools: ● Hub: hub.github.com ● silverstripe/upgrader: github.com/silverstripe/silverstripe-upgrader
  • 7. Composer ● List your forks as VCS repositories until merged ● Projects: "minimum-stability": "dev" and "prefer-stable": true ● "extra": { "branch-alias": { "dev-master": "2.x-dev" } }
  • 8. Modules: Get into it, now! ● The more SilverStripe 4 compatible a module is, the more likely you and other developers will use it, and recommend it for use to those you work for ● Upgrading a module will give you a much deeper understanding of how it works, especially if you didn't write it!
  • 9. Namespacing and PSR-4 People asked, SilverStripe responded. Please welcome namespacing to the stage! With it comes PSR-4 compatible autoloading, which makes sense. ● Use "git mv" to configure your module for PSR-4 compatibility without losing history ● Add and implement namespaces with the upgrader ● Do these in separate commits/PRs from PSR-2 linting
  • 12. Implementing PSR-4 Tip: don't forget to run composer validate!
  • 13. The framework has switched to using dotenv for configuration. It's worth mentioning now, because you won't be able to "build" without it. File: .env Hello dotenv, bye bye _ss_environment
  • 14. In SilverStripe the suggested PHP style guideline to follow is PSR-2 (which includes PSR-1). This means spaces for indentation, brackets on new lines, sensible spacing, etc. You can automate most of the required changes using PHP CodeSniffer and the PSR2 standard it ships with. More info: php-fig.org/psr/psr-2 PHP style guidelines: PSR-1/2
  • 15. ● In 3.x: Page_Controller ● In 4.x: PageController Don't forget to add this to the .upgrade.yml mapping! Move the controller to its own file now - PSR-2 requires each class to be on its own. Naming controllers
  • 16. In SilverStripe 3.x you can mostly put templates wherever you feel like. With 4.x things are stricter: ● Default: fully qualified template location matches class namespace ● ->renderWith('TemplateName'): still looks in root of "templates" SilverStripe encourages the use of fully qualified template locations where possible, even if you don't have to move them when you upgrade! Naming templates
  • 17. DataObject table names By default a namespaced DataObject will use a backslash in the table name, matching the namespace. To replace this, or to provide backwards compatibility, specify private static $table_name = 'MyTableName'; on your DataObject. BuildTask segments BuildTasks will use a fully qualified class name (sanitised) for the segment. You may see dev/tasks/Robbie-MeetupDemo-Task-DoesNothingTask. To make this simpler, add private static $segment = 'DoesNothingTask'; to your task. Small gotchas
  • 18. ● "ClassName" value remapping When working with existing data (i.e. upgrade, not fresh install), if your DataObject has a ClassName field, it will need to become fully qualified in legacy date. Use YAML config - see the CMS module for an example. ● php-intl extension is now required ● Upgrader bugs: Still in development too - it will occasionally replace things it shouldn't. Doesn't update YAML configuration files (yet). This also applies to YAML fixtures in unit test - they must be fully qualified! More gotchas...
  • 19. Handling files, or whatever ● Asset abstraction provides secure assets out of the box as well as versioning and coupling with campaigns ● The upload process changes ● The image manipulation public API has changed a bit ● Take a look at the changelog
  • 20. Mono-Logging! SS_Log is still available, but it's deprecated - you shouldn't and probably can't use it. Instead, use Monolog (PSR-3 compatible) via the Injector: More: github.com/Seldaek/monolog
  • 21. Cascading themes! As very cool feature - now you can have multiple themes that inherit from each other! This includes looking up resources by their base filename across any registered theme.
  • 22. Deprecation and removals ● All deprecation and removals are documented in the 4.0.0 changelog, which is kept up to date ● If your code complains, check for updates ● Some important backends have been updated or replaced entirely: logging, config (shortly), localisation, cache (soon)
  • 23. Considerations ● Entwine being phased out in favour of ReactJS (CMS) ● Use Webpack or similar for bundling assets ● REST API modules replaced with core GraphQL ● RestfulService gone, use guzzlehttp/guzzle or similar ● Use the injector wherever you can
  • 24. General tips ● Good unit test coverage to start with will help a lot ● Start namespacing early if you can (SS3 can handle it, to an extent) ● Use the upgrader tool ● Bump your branch alias ● Release alpha tags for your upgraded code
  • 25. Useful links ● docs.silverstripe.org/en/4/changelogs/4.0.0 ● github.com/silverstripe/silverstripe-upgrader ● github.com/robbieaverill/meetup-demo ● hub.github.com ● gist.github.com/robbieaverill/cad0260414226645b404c 45b2059fdf9
  • 26. Thank you! Twitter: @robbieaverill Email: robbie@silverstripe.com 22nd Feb 2017 • Robbie Averill