# Is there a way to use Sage 9 with PHP 8.1?

**URL:** https://discourse.roots.io/t/is-there-a-way-to-use-sage-9-with-php-8-1/24435
**Category:** sage
**Tags:** sage9
**Created:** 2022-12-20T08:14:43Z
**Posts:** 7

## Post 1 by @Clementine_FERNANDEZ — 2022-12-20T08:14:43Z

Hello guys,  
I have to upgrade Php version from 7.4 to 8.1 on my project.  
Unfortunately Sage 9 doesn’t seem to be compatible with php 8.1.  
Some dependencies blocked the migration : illuminate/support for example.

Some of you did find a way to migrate your php version ?

Thanks a lot for your help !

---

## Post 2 by @evance — 2022-12-20T10:03:39Z

Hi @Clementine_FERNANDEZ,

I upgraded a Sage 9-project just recently to work with PHP 8.1 so I can gladly share what worked for me:

Essentially you’d have to replace the `sage-installer` and `sage-lib` packages in the theme’s `composer.json` to use the forked variants that have been updated to work with PHP 8.x.

This is my composer-file:

```
{
  "name": "roots/sage",
  "type": "wordpress-theme",
  "license": "MIT",
  "description": "WordPress starter theme with a modern development workflow",
  "homepage": "https://roots.io/sage/",
  "authors": [
    {
      "name": "Ben Word",
      "email": "ben@benword.com",
      "homepage": "https://github.com/retlehs"
    },
    {
      "name": "Scott Walkinshaw",
      "email": "scott.walkinshaw@gmail.com",
      "homepage": "https://github.com/swalkinshaw"
    },
    {
      "name": "QWp6t",
      "email": "hi@qwp6t.me",
      "homepage": "https://github.com/qwp6t"
    }
  ],
  "keywords": ["wordpress"],
  "support": {
    "issues": "https://github.com/roots/sage/issues",
    "forum": "https://discourse.roots.io/"
  },
  "autoload": {
    "psr-4": {
      "App\\": "app/"
    }
  },
  "repositories": [
    { "type": "vcs", "url": "https://github.com/jeh5256/sage-installer" },
    { "type": "vcs", "url": "https://github.com/jeh5256/sage-lib" }
  ],
  "require": {
    "php": "^7.4|^8.0",
    "composer/installers": "^2.0",
    "soberwp/controller": "~2.1.0",
    "roots/sage-installer": "^2.0",
    "roots/sage-lib": "dev-master",
    "log1x/blade-svg-sage": "dev-chore/illuminate-8.x"
  },
  "require-dev": {
    "squizlabs/php_codesniffer": "^2.8.0",
    "filp/whoops": "^2.12"
  },
  "scripts": {
    "test": ["phpcs"],
    "post-create-project-cmd": [
      "Roots\\Sage\\Installer\\ComposerScript::postCreateProject"
    ]
  }
}
```

Note that I reorder the packages slightly and referenced the `log1x/blade-svg-sage` which is optional but also needs an update to be compatible, thus listing this as well.

If I remember correctly the `illuminate/support`-package is listed as a dependency with another package so it can be safely omitted here.

Compare to Sage 9’s default [composer.json](https://github.com/roots/sage/blob/7e6d0671d3421acadb6e9b3d0bad2a9f54d62c67/composer.json).

Let me know if that works out for you!

---

## Post 3 by @Clementine_FERNANDEZ — 2022-12-20T11:19:04Z

> [@evance](#):
>
> ```
> "require": {
> "php": "^7.4|^8.0",
> "composer/installers": "^2.0",
> "soberwp/controller": "~2.1.0",
> "roots/sage-installer": "^2.0",
> "roots/sage-lib": "dev-master",
> "log1x/blade-svg-sage": "dev-chore/illuminate-8.x"
> },
> "require-dev": {
> "squizlabs/php_codesniffer": "^2.8.0",
> "filp/whoops": "^2.12"
> },
> ```

Thanks a lot for your help @evance .  
This solution doesn’t work for me, I still have issues when I run composer update :

```
Problem 1
    - Root composer.json requires roots/sage-installer ^2.0, found roots/sage-installer[dev-master, dev-tailwind-2-support, dev-bulma-scss-fix, dev-bootstrap-4.3.0, dev-bootstrap-4.3.1, 1.0.0, ..., 1.6.4] but it does not match the constraint.

Problem 2
    - Root composer.json requires roots/sage-lib dev-master -> satisfiable by roots/sage-lib[dev-master].
    - roots/sage-lib dev-master requires composer/installers ~1.0 -> found composer/installers[v1.0.0, ..., v1.12.0] but it conflicts with your root composer.json require (^2.0).
```

---

## Post 4 by @evance — 2022-12-20T11:33:33Z

Yes, because you didn’t change / add the necessary **repositories** – please review the complete `composer.json` I’ve posted and compare it to the Sage 9 default in order to spot all the changes.

---

## Post 5 by @Clementine_FERNANDEZ — 2022-12-20T14:10:27Z

> [@evance](#):
>
> ```
> "repositories": [
> { "type": "vcs", "url": "https://github.com/jeh5256/sage-installer" },
> { "type": "vcs", "url": "https://github.com/jeh5256/sage-lib" }
> ],
> ```

Okay it’s clear now, thanks a lot !

---

## Post 6 by @hypotune — 2023-03-10T18:13:53Z

I used @evance’s composer example to update Sage 9 on php 8.1 but I encountered illuminate/filesystem/Filesystem errors.

Removing blade-svg-sage and installing illuminate/support resolved the issue for me.

```
% composer remove log1x/blade-svg-sage  
% composer require illuminate/support
```

---

## Post 7 by @evance — 2024-04-10T06:55:51Z

The `log1x/blade-svg-sage`-package doesn’t exist with _“dev-chore/illuminate-8.x”_ any more so instead the whole **require** -block should read:

```
"require": {
  "php": "^7.4|^8.0",
  "composer/installers": "^2.0",
  "soberwp/controller": "~2.1.0",
  "roots/sage-installer": "^2.0",
  "roots/sage-lib": "dev-master",
  "log1x/blade-svg-sage": "^3.0"
},
```

If you do not want / need to use `log1x/blade-svg-sage` then you have to `composer require illuminate/support` explicitely.
