Hi there,

I have a single drupal site on shared hosting. I had been updating the site manually via FTP but was running into php error problems when updating due to non-core modules. I have been advised to use composer to update the site. However the article about installing composer on an existing site states that you should modify the composer.json file that is at the root of your git repository, not core/composer.json. https://www.drupal.org/node/2718229#managing-existing-site

I don't use git because I am on shared hosting and was simply using Filezilla to upload to the server.

What am I best doing here?

Thanks

Comments

sprite’s picture

There isn't any problem with installing composer directly in the docroot of your one Drupal site.
Once you install composer, then use composer to manage all your core and module installations and updates.

With composer installed add modules by using "composer require drupal/{module}"
Then enable the module on the admin/extend page.

Always run {site}/update.php after running "composer update".

Here is an example composer.json for use in the docroot of your D8 site, along with some essential contrib modules no site should be without:


{
    "name": "drupal/drupal",
    "description": "Drupal is an open source content management platform powering millions of websites and applications.",
    "type": "project",
    "license": "GPL-2.0+",
    "require": {
    	"drush/drush": "^8.1",
        "phpdocumentor/reflection-docblock": "^2.0",
        
        "composer/installers": "^1.0.21",
        "wikimedia/composer-merge-plugin": "~1.3",
        "drupal/core": "^8.3",

        "drupal/admin_toolbar": "1.19.0",        
        "drupal/module_filter": "3.0.0",
        "drupal/metatag": "~1.1",                                      
        "drupal/password_policy": "^3.0@alpha",
        "drupal/token": "1.0.0",
        "drupal/ultimate_cron": "2.0.0-alpha1",
        "drupal/pathauto": "^1.0",
        "drupal/xmlsitemap": "~1.0"
    },
    "replace": {
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "config": {
        "preferred-install": "dist",
        "autoloader-suffix": "Drupal8"
    },
    "extra": {
        "_readme": [
            "By default Drupal loads the autoloader from ./vendor/autoload.php.",
            "To change the autoloader you can edit ./autoload.php."
        ],
        "merge-plugin": {
            "include": [
                "core/composer.json"
            ],
            "recurse": false,
            "replace": false,
            "merge-extra": false
        }
    },
    "autoload": {
        "psr-4": {
            "Drupal\\Core\\Composer\\": "core/lib/Drupal/Core/Composer",
            "Drupal\\composer_manager\\Composer\\": "modules/composer_manager/src/Composer"
        }
    },
    "scripts": {
        "pre-autoload-dump": "Drupal\\Core\\Composer\\Composer::preAutoloadDump",
        "post-autoload-dump": "Drupal\\Core\\Composer\\Composer::ensureHtaccess",
        "post-package-install": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup",
        "post-package-update": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup",
        "drupal-rebuild": "Drupal\\composer_manager\\Composer\\Command::rebuild",
        "drupal-update": "Drupal\\composer_manager\\Composer\\Command::update"
    },
    "repositories": {
        "drupal": {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    }
}



spritefully yours
Technical assistance provided to the Drupal community on my own time ...
Thank yous appreciated ...

adminMN2023’s picture

If you have cPanel - you can easily repeat your FTP process using File Manager without resorting to composer (file manager seems to be a lot more stable than the FTP process). But it may be smart to jump into Composer and learn it.