Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Installing SilverStripe /

Getting SilverStripe up and running on your computer and on your web server.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Using Composer to install and update modules


Go to End
Reply


15 Posts   5689 Views

Avatar
_Matt

Community Member, 27 Posts

16 November 2012 at 6:59am

Hi, I'm just testing out using Composer to install a site and modules by following the instructions here: http://doc.silverstripe.org/framework/en/installation/composer

The site installs fine and I'm able to set it up through my browser. However, I'm having problems running 'composer update', or installing modules such as 'composer require silverstripe/subsites:*'.

I basically get the same error message:

"composer.json has been updated
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

Problem 1
- The requested package silverstripe/cms 1.0.0 could not be found.
Problem 2
- The requested package silverstripe/framework 1.0.0 could not be found."

Any ideas what's happening here? Thanks :)

Avatar
_Matt

Community Member, 27 Posts

16 November 2012 at 9:18am

Having had a closer look at the files I tried updating the composer.json file and this seems to have done the trick.

Initially there's a section that says:

"silverstripe/cms": "self.version",
"silverstripe/framework": "self.version",

I changed this to:

"silverstripe/cms": "*",
"silverstripe/framework": "*",

I don't know if this is the correct thing to do, but it seems to work. If anyone can tell me if what I've done is ok that would be much appreciated. Thanks.

Avatar
elgordo

Community Member, 70 Posts

21 November 2012 at 9:26pm

hi _Matt

Thanks for that, got me past the same problem.

Regards

Gordon

Avatar
elgordo

Community Member, 70 Posts

22 November 2012 at 1:42am

Edited: 22/11/2012 1:42am

hi

With the addition of the blog and forum modules, I ended up with the following in my composer.json file:

{
   "name": "silverstripe/installer",
   "description": "The SilverStripe Framework Installer",
   "require": {
      "php": ">=5.3.2",
      "silverstripe/cms": "3.0.2.1",
      "silverstripe/framework": "3.0.2.1",
      "silverstripe-themes/simple": "*",
"silverstripe/forum": "*",
"silverstripe/blog": "*"
   },
   "require-dev": {
      "silverstripe/compass": "*",
      "silverstripe/docsviewer": "*"
   },
   "minimum-stability": "dev"
}

I had to set the version number for the framework and cms explicitly as otherwise the head of master was used, which is not what I want.

Cheers

Gordon

Avatar
Ingo

Forum Moderator, 801 Posts

22 November 2012 at 6:02am

The "composer create-project" command is trickier than it looks...
If you install from a tag like 3.0.2.1, it'll use the github-generated ZIPs by default, for both root and dependencies.
Which means it can't infer version information from git on a "composer require" or "composer update" call.
You can verify which version composer thinks its on by using "composer show --self".

Using the ZIPs is much, much faster than a full git checkout, so in general its a good default,
if it wasn't for that limitation around version introspection.

Symfony gets around this by requiring release branches in their composer.json, rather than "self.version":
https://github.com/symfony/symfony-standard/blob/v2.1.3/composer.json
http://symfony.com/download
That's not great either though, as it means "create-project" with a tag argument is not actually respected in dependencies.

Related discussions:
https://github.com/composer/composer/issues/578
https://github.com/composer/composer/issues/1089
https://github.com/composer/composer/issues/1229

Some stopgap fixes:
- install from a branch (3.0.x-dev)
- use the "--prefer-source" flag
- COMPOSER_ROOT_VERSION=3.0.2.1

I think in the end, composer needs to track this information somewhere in its metadata.

Avatar
elgordo

Community Member, 70 Posts

22 November 2012 at 7:27am

hi Ingo

Thanks for the feedback, I will read the discussions tomorrow

Cheers

Gordon

Avatar
elgordo

Community Member, 70 Posts

22 November 2012 at 4:34pm

hi Ingo

Ok I think I understand the issue with version introspection now, thanks for your detailed reply. Looking at the symfony example, it does look like version numbers need to be hardcoded in composer.json which is not ideal, as it prevents the automatic update for new versions of modules when running composer update. In effect, it is almost like creating the lock file.

The documentation for installing SilverStripe using Composer is with respect to the above problems incorrect and needs fixing. Is open.silverstripe.org the most appropriate place to register a documentation issue?

Cheers

Gordon

Avatar
Sam

Administrator, 685 Posts

22 November 2012 at 6:18pm

I think the fix we need to make is to patch silverstripe/installer (github.com/silverstripe/silverstripe-installer) to have hard-coded version references.

Perhaps we can do this before 3.0.3?

Go to Top