Silverstripe 4.7.3 seems to require php 8

<%- if @topic_view.topic.tags.present? %>
<%= t 'js.tagging.tags' %>: <%- @topic_view.topic.tags.each do |t| %> <%= t %> <%- end %>
<% end %>

Silverstripe 4.7.3

Does Silverstripe 4.7.3 have to use PHP 8

I installed Silverstripe 4.7.3 via composer and on loading the site to begin the configuration was presented with the message:

Parse error : syntax error, unexpected ‘|’, expecting variable (T_VARIABLE) in /Users/phillbexon/Dropbox/Websites/AccessIT/SemietaV3/webfiles/vendor/psr/cache/src/CacheItemInterface.php on line 104

On digging further, it would appear that the composer command I used:

composer create-project silverstripe/installer webfiles

Installs PSR/Cache (2.0.0) which has a minimum PHP version of 8

I did wonder if this version was installed because I added --ignore-platform-reqs onto the composer command, however, running composer without it give me an error about ext-intl not being installed although it actually is installed which I verified with ‘PHP -m’

Does anyone have any thoughts on how I can resolve it so that it runs under php 7.4?

Got the same problem here when I used the --ignore-platform-reqs composer flag.

The problem is that when you use this flag, composer ignores any PHP constraint and will try to install the latest compatible module version, which may include PHP8 only packages.

If omitting the --ignore-platform-reqs flag is not an option, I would suggest explicitly adding a requirement for "psr/cache": "^1" in your project’s composer.json file which will force the installation of the older package.

Keep in mind that this will become increasingly difficult to manage over time as more and more packages start shipping PHP8 only version.

Thanks for that, I thought it would be related to the --ignore-platform-reqs, I really dislike composer, I miss the days when you could just download it from the website!

Any idea on how to fix the ext-int problem, going by Google, it would appear that it is a common problem and most the time it is because the version of PHP running on the command line is different from the browser, however in my case it is the same version and running PHP -m list “intl” among the modules?

I figured out the reason for the ext-int problem. Even though php -v in the command line indicated it was using PHP 7.4 which had ext-int installed, composer was using PHP 7.3 which didn’t (presumably because it was installed prior to installing MAMP Pro and enabling PHP 7.4 in the command line).

I couldn’t work out how to change the PHP version that composer uses so ended up installing a local version of composer using the PHP commands on the getcomposer website. This placed a composer.phar file in my local directory which I could run with PHP.