Download the PHP package silverstripe/upgrader without Composer

On this page you can find all versions of the php package silverstripe/upgrader. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package upgrader

The Silverstripe CMS Upgrader has mostly served its purpose. The core Silverstripe CMS team is not actively looking at doing more work on it in the near future. If a community member would like become a maintainer, then we're happy to grant them merge access after some basic due diligence. Please raise an issue to let us know if you would like to maintain this repo.

Upgrader

Build Status SilverStripe supported module

Upgrader is a framework for automating the upgrade of code to handle API changes in dependent libraries. See the 4.x upgrading guide for step-by-step instructions.

Developed by @sminnee and @tractorcow with inspiration and encouragement from @camspiers

Install

The upgrader is available as a phar executable.

To install the PHAR executable:

  1. Download the upgrader as a PHAR executable or wget https://silverstripe.github.io/silverstripe-upgrader/upgrade-code.phar
  2. Make the file executable chmod +x upgrade-code.phar
  3. Move the file to a folder in your path, for example sudo mv upgrade-code.phar /usr/local/bin/upgrade-code

Install the upgrader globally with composer

You can install the upgrader globally with composer. This can make it easier to update to newer releases, however you can get dependency conflicts if you have other packages installed globally.

To install globally run:

composer global require silverstripe/upgrader

Make sure your $HOME/.composer/vendor/bin directory is in your PATH (or the equivalent for your OS e.g. C:\Users\<COMPUTER NAME>\AppData\Roaming\Composer\vendor\bin on Windows).

echo 'export PATH=$PATH:~/.composer/vendor/bin/' >> ~/.bash_profile

Then you can run this script with upgrade-code <command> in your project root. If not running in the root, use --root-dir=/path.

Available commands

Overview

The following commands are available:

all

Run all commands in the recommended order with sensible default values.

Example:

add-namespace

You can run the below to add namespace to any class

Example:

This will namespace the class file SomeCode.php, and add the mapping to the ./.upgrader.yml file in your project.

Once you've added namespaces, you will need to run the upgrade task below to migrate code that referenced the un-namespaced versions of these classes.

recompose

You can use this command to upgrade your composer.json dependencies from SilverStripe 3 to Silverstripe 4.

Example:

doctor

When migrating from prior versions certain project resources (e.g. .htaccess / index.php) could be outdated and leave the site in an uninstallable condition.

You can run the below command on a project to run a set of tasks designed to automatically resolve these issues:

Tasks can be specified in .upgrade.yml with the following syntax:

The given task must have an __invoke() method. This will be passed the following args:

Note: It's advisable to only run this if your site is non-responsive, as these may override user-made customisations to .htaccess or other project files.

environment

You can use this command to migrate an SilverStripe 3 _ss_environment.php file to the .env format used by SilverStripe 4.

Example:

inspect

Once a project has all class names migrated, and is brought up to a "loadable" state (that is, where all classes reference or extend real classes) then the inspect command can be run to perform additional automatic code rewrites.

This step will also warn of any upgradable code issues that may prevent a successful upgrade.

Note: This step is separate from upgrade because your project code is loaded into real memory during this step in order to get the complete project context. In order to prepare for this step your site should be updated to a basic stage, including all module upgrades and namespace changes.

You can run this command (with a necessary refresh of composer autoload files) with the below:

This will load all classes into memory and infer the types of all objects used in each file. It will use these inferred types to automatically update method usages.

Visibility updates

The command updates properties and functions to use the correct visibility of its parent if possible.

Add the --skip-visibility option to ignore this.

reorganise

You can use this command to reorganise your folder structure to conform to the new structure introduced with SilverStripe 4.1. Your mysite folder will be renamed to app and your code folder will be rename to src.

upgrade-code reorganise [--root-dir=<dir>] [--write] [--recursive] [-vvv]

Example:

upgrade-code reorganise --root-dir=/var/www/SS_project --write -vvv

self-update

This command will update the upgrader tool itself to the newest release. It does not take any arguments. It's important to keep the tool updated since its under active development, and continuously improves.

upgrade

Once you have finished namespacing your code, you can run the below code to rename all references.

Example

This will look at all class maps, and rename any references to renamed classes to the correct value.

In addition all .yml config files will have strings re-written. In order to upgrade only PHP files you can use the --rule=code. If you have already upgraded your code, you can target only config files with --rule=config.

Excluding strings from upgrade

When upgrading code that contains strings, the upgrader will need to make assumptions about whether a string refers to a class name or not, and will determine if that is a candidate for replacement.

If you have a code block with strings that do not represent class names, and thus should be excluded from rewriting (even if they match the names of classes being rewritten) then you you can add a docblock with the @skipUpgrade tag, and the upgrader will not alter any of this code.

Example:

In the above example, MyService will not be modified even if it would otherwise be renamed.

This doc block can be applied either immediately before the statement with the string, or before a block of code (such as a method, loop, or conditional).

Note that @skipUpgrade does not prevent upgrade of class literals, and only affects strings, as these are not ambiguous, and the upgrader can safely update these references.

Upgrading Database references to now namespaced DataObject subclasses

If any DataObject subclasses have been namespaced, we will need to specify them in a config file ie. legacy.yml. This tells SilverStripe to remap these class names when dev/build is run.

Upgrading localisations

You can also upgrade all localisation strings in the below files:

You can run the upgrader on these keys with the below command:

Since this upgrade is normally only done on projects that provide their own strings, this rule is not included by default when running a normal upgrade.

Class renaming

Class mappings can be used to convert string literal references to namespaced classes. Sometimes it is unclear whether a string literal is referring to the mapped class or not. This is where renameWarnings are handy.

An example of an ambiguous rename would be:

You can specify what class renames should be considered ambiguous with yaml:

The above config will show warnings when renaming the File and Image occurrences to their respectful class mappings.

Add the --prompt option to manually approve ambiguous class renames.

.upgrade.yml spec

The .upgrade.yml file will follow the below spec:

webroot

Configure your project to use the public web root structure introduced with SilverStripe 4.1 (details.

Example:


All versions of upgrader with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1
nikic/php-parser Version ^3.1
symfony/console Version ^3.2 || ^4
symfony/yaml Version ^3.2
phpspec/php-diff Version ^1
phpstan/phpstan Version ~0.9.0
phpstan/phpstan-php-parser Version ~0.9.0
m1/env Version ^2.1
ext-json Version *
composer/semver Version ^1.4
guzzlehttp/guzzle Version ^6.3
symfony/process Version ^3.2 || ^4
symfony/filesystem Version ^3.2 || ^4
padraic/phar-updater Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package silverstripe/upgrader contains the following files

Loading the files please wait ....