What is the correct way to get the latest composer.json?

I started working on a Statamic site a few months ago using the Statamic CLI to install the base "statamic/statamic" project. I have been updating Statamic when new versions come out via Composer. After installing a new version of "statamic/statamic" the other day I noticed that the "composer.json" file has different "require" and "require-dev" dependencies listed in it compared to my older install from a few months ago. Both sites are running the latest version of Statamic in the same development environment, but they are not running the same versions of Laravel (7 vs. 8) and other dependencies. See "composer.json" files below for more details.

  1. Is it safe to delete the "composer.json" and "composer.lock" files on the original Statamic site and replace the old "composer.json" file with the new one that requires newer versions of ""guzzlehttp/guzzle", "laravel/framework", etc. to get the newest dependencies for my Statamic install?
  2. Should I also delete the "vendor" directory before running composer update?
  3. Is this the best way to get the latest dependencies for existing Statamic installs?
  4. Should I plan on doing this on a regular basis on my Statamic sites to keep everything up to date?

What is the correct way to get the latest composer.json and dependencies for my Statamic sites?

Old Statamic - composer.json

{
    "name": "statamic/statamic",
    "description": "Statamic",
    "keywords": ["statamic", "cms", "flat file", "laravel"],
    "type": "project",
    "require": {
        "php": "^7.2.5",
        "fideloper/proxy": "^4.2",
        "fruitcake/laravel-cors": "^1.0",
        "guzzlehttp/guzzle": "^6.3",
        "laravel/framework": "^7.0",
        "laravel/tinker": "^2.0",
        "statamic/cms": "3.0.*"
    },
    "require-dev": {
        "barryvdh/laravel-debugbar": "^3.2",
        "facade/ignition": "^2.0",
        "fzaninotto/faker": "^1.9.1",
        "mockery/mockery": "^1.3.1",
        "nunomaduro/collision": "^4.1",
        "phpunit/phpunit": "^8.5"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi",
            "@php artisan statamic:install --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

New Statamic - composer.json

{
    "name": "statamic/statamic",
    "description": "Statamic",
    "keywords": ["statamic", "cms", "flat file", "laravel"],
    "type": "project",
    "require": {
        "php": "^7.3 || ^8.0",
        "fideloper/proxy": "^4.2",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^7.0.1",
        "laravel/framework": "^8.0",
        "laravel/tinker": "^2.0",
        "statamic/cms": "3.0.*"
    },
    "require-dev": {
        "barryvdh/laravel-debugbar": "^3.5",
        "facade/ignition": "^2.3.6",
        "fzaninotto/faker": "^1.9.1",
        "mockery/mockery": "^1.3.1",
        "nunomaduro/collision": "^5.0",
        "phpunit/phpunit": "^9.3"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Database\\Factories\\": "database/factories/",
            "Database\\Seeders\\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi",
            "@php artisan statamic:install --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}
Answered by Christopher Zavatchen!
>>>>>>> Answered <<<<<<<
1 Reply
1 Follower