diff --git a/README.md b/README.md index c0ac7a68..a830b155 100644 --- a/README.md +++ b/README.md @@ -36,9 +36,11 @@ First add `cakephp/chronos` to your `composer.json`: php composer.phar require cakephp/chronos ``` -To update your code you will need to update imports and typehints. Assuming -`src` contains the files you want to migrate, we could use the following to -update files: +By default Chronos includes a compatiblity script that creates aliases for the +relevant Carbon classes. This will let most applications upgrade with very +little effort. If you'd like to permanently update your code, you will +need to update imports and typehints. Assuming `src` contains the files you +want to migrate, we could use the following to update files: ``` # Replace imports diff --git a/composer.json b/composer.json index 7ddab168..d9da42ad 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,8 @@ "autoload": { "psr-4": { "Cake\\Chronos\\": "src" - } + }, + "files": ["src/carbon_compat.php"] }, "autoload-dev": { "psr-4": { diff --git a/src/carbon_compat.php b/src/carbon_compat.php new file mode 100644 index 00000000..104ff569 --- /dev/null +++ b/src/carbon_compat.php @@ -0,0 +1,17 @@ + + * @link http://cakephp.org CakePHP(tm) Project + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ + +// Create class aliases for Carbon so applications +// can upgrade more easily. +class_alias('Cake\Chronos\Chronos', 'Carbon\MutableDateTime'); +class_alias('Cake\Chronos\ChronosInterface', 'Carbon\CarbonInterface');