Jump to:

4895 Posts in 7193 Topics by 1472 members

Installing SilverStripe

SilverStripe Forums » Installing SilverStripe » Using Composer to install and update modules

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

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

Page: 1 2
Go to End
Author Topic: 3531 Views
  • _Matt
    Avatar
    Community Member
    24 Posts

    Using Composer to install and update modules Link to this post

    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

  • _Matt
    Avatar
    Community Member
    24 Posts

    Re: Using Composer to install and update modules Link to this post

    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.

  • elgordo
    Avatar
    Community Member
    69 Posts

    Re: Using Composer to install and update modules Link to this post

    hi _Matt

    Thanks for that, got me past the same problem.

    Regards

    Gordon

  • elgordo
    Avatar
    Community Member
    69 Posts

    Re: Using Composer to install and update modules Link to this post

    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

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Using Composer to install and update modules Link to this post

    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.

  • elgordo
    Avatar
    Community Member
    69 Posts

    Re: Using Composer to install and update modules Link to this post

    hi Ingo

    Thanks for the feedback, I will read the discussions tomorrow

    Cheers

    Gordon

  • elgordo
    Avatar
    Community Member
    69 Posts

    Re: Using Composer to install and update modules Link to this post

    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

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: Using Composer to install and update modules Link to this post

    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?

    3531 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.