Fatal error: Declaration of Drupal\Component\DependencyInjection\Container::set($id, $service) must be compatible with Symfony\Component\DependencyInjection\ContainerInterface::set($id, $service, $scope = self::SCOPE_CONTAINER) in C:\inetpub\wwwroot\nssl\web\core\lib\Drupal\Component\DependencyInjection\Container.php on line 47
I have, for my sins, been forced to use IIS at work. Let’s not talk about how hard it is to find error logs.
Actually, let’s, just for a minute so I can blow off some steam. I have 9 sites and the error log folder looks like this:
(And no, IIS doesn’t make it easy to see which site belongs to which randomly assigned number. Want to either check each folder one by one or spend 20 minutes googling this, plus where the php.ini and php logs are? Sound like fun? Then IIS is the server for you, buddy.)
Anyway. Because I am heartily sick of other people not putting enough basic information for people who have never used composer, I am going to describe exactly (as far as I can remember), what I have done to get this error. First I installed composer and git, then I made a site in IIS, and then, in the folder I made for the IIS site:
1. Followed the instructions here for Option A https://www.drupal.org/node/2718229 to create a new site, created a db for the site and made a settings.php based on the default file given.
2. Followed the instructions here https://github.com/drupal-composer/drupal-project to add dependencies to the project (e.g.
composer require drupal/devel:~1.0
this adds stuff to composer.json)
3. Committed all of this to a git repo. There should be a gitignore that comes with the composer/drupal-project, I just used that. The git repo is here https://github.com/rukayaj/ssp
4. The IIS site should be working fine now, as far as I remember I didn’t have to do anything special to it. Now if you want to get another version of this up and running you need to git clone, and then composer install. I then wanted to update Drupal, and I followed https://www.drupal.org/docs/8/update/update-procedure-in-drupal-8 and did composer outdated, and then composer update drupal/core —with–dependencies. This gave me that fatal error.
To fix it, you have to delete the vendor folder (was hard to get this unlocked in windows, ended up having to restart the server) and the web/core folder. Then do composer install again, and it should work. Very odd.
I actually think there might be a mistake in the gitignore for drupal-composer/drupal-project. It says Ignore directories generated by composer, and it only lists /vendor/ which doesn’t seem to work? Presumably it needs /vendor/ and /vendor/*? No, apparently something odd just happened with my set up. Removing the /vendor/ folder from git just took running
git rm --cached -r vendor
And committing + pushing that. And now it all seems hunky dory. Hurrah.