composer require laravel/breeze --dev has an issue with php version - php

I launch the command in terminal from my laravel project:
composer require laravel/breeze --dev
But this is my error:
[InvalidArgumentException]
Package laravel/breeze has a PHP requirement incompatible with your PHP version, PHP extensions and Composer version
If I type php -v :
PHP 7.1.33 (cli) (built: Jan 18 2020 13:49:07) ( NTS )
Then with brew upgrade phpI have error Error: php not installed.
So I do brew install php .
Response is:
Warning: You are using macOS 10.13.
We (and Apple) do not provide support for this old version.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
old version.
Error: php: no bottle available!

Try to install php7.3 via brew. your current version is probably installed by macOS.
brew install php#7.3
Dont forget to export the new path
echo 'export PATH="/usr/local/opt/php#7.3/bin:$PATH"'

Related

Composer 2.3.0 dropped support for PHP less than 7.2.5 and you are running 7.1.33

Facing issue after downgrade the PHP version with updated version of composer,
I am trying to doing upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2 which option is given by CMD.
I tried myself with downgrade the PHP version using the Command of brew but I tried to get the solution for composer, Either it's possible to downgrade or upgrade the version of composer same like PHP.

Upgrading php to 8

Both my valet and composer is using php 8.0
But my local says
Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.2". You are running 7.4.30. in /Users/admin/sites/sage10/web/app/themes/sage10/vendor/composer/platform_check.php on line 24
When I upgrade php with valet using 8.0 it gives
Deprecated: Method ReflectionParameter::getClass() is deprecated in /Users/admin/.composer/vendor/illuminate/container/Container.php
But at the end it says its using 8.0. and composer -vvv about also gives php 8.0
Is there more things to consider? I don't understand why its saying I'm using 7.4...
Composer works on the php version is in use on command line. It is possible you have multiple version installed.
Try to run
php -v
Then ensure composer is updated to the latest version (2.4.2)
composer -V
In case update it
composer self-update
If self-update gives you some runtime error, reinstall composer following the install procedure
Then the error you get is about Laravel 6/7/8 version with PHP 8, the solution is here
Laravel app stopped working after upgrading to php 8
I had a line of required package that was not needed and supported with sage 10// php8 (illuminate/support) inside my global composer file. After erasing that and linking my valet with php database and restarting it, everything started to work.

pecl fails installing mongodb driver on Apple Silicon (M1)

I have php 7.4 installed on my macbook pro m1
% php -v
PHP 7.4.15 (cli) (built: Feb 26 2021 09:28:23) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.15, Copyright (c), by Zend Technologies
I'm trying to install the mongodb driver running:
sudo pecl install mongodb
But fails after a while:
mp/pear/temp/mongodb/src/contrib/ -DHAVE_CONFIG_H -g -O2 -c /private/tmp/pear/temp/mongodb/php_phongo.c -fno-common -DPIC -o .libs/php_phongo.o
In file included from /private/tmp/pear/temp/mongodb/php_phongo.c:29:
In file included from /opt/homebrew/Cellar/php#7.4/7.4.15_1/include/php/ext/spl/spl_iterators.h:24:
/opt/homebrew/Cellar/php#7.4/7.4.15_1/include/php/ext/pcre/php_pcre.h:25:10: fatal error: 'pcre2.h' file not found
#include "pcre2.h"
^~~~~~~~~
1 error generated.
make: *** [php_phongo.lo] Error 1
ERROR: `make' failed
I tried with
arch -x86_64 sudo pecl install mongodb
but results in the same error.
Somebody knows how can I solve this please? Or if I can install the mongodb driver without using pecl. Thanks in advance.
I have finally solved my problem.
I followed these steps from https://github.com/mongodb/mongo-php-driver/issues/1159
After installing a newer PHP version where previously I used 7.3.24 and updated to 7.4.16.
Still had the same issue but diffrent file:
fatal error: 'pcre2.h' file not found #include "pcre2.h"
From this error I tried to check the files in the MacOs Big Sur File system and in the end I found where the pcre2.h is located, and oddly it was being called in the pcre folder, so I manually copied from the pcre2 folder to pcre
The solution that I used:
$cp /opt/homebrew/Cellar/pcre2/10.36/include/pcre2.h /opt/homebrew/Cellar/php\#7.4/7.4.16/include/php/ext/pcre/pcre2.h
Then, I installed mongodb using
$brew install mongodb
After that, I once again tried
$sudo pecl install mongodb
Finally, it worked. However, I'm not sure if this is a good way to solve the problem by manually adding a header file to the directory.
(Sorry I'm still new to the MacOs Environment, just bought a mac mini m1 last week for developing my programming skills)
If you were to install php multiple versions from homebrew make sure you are using the current version as you wanted to. You could check the version by using which php.
To switch from 7.4 to 5.6
$brew unlink php#7.4
$brew link php#5.6 --force
credits: https://www.markhesketh.com/switching-multiple-php-versions-on-macos/
New error
Success Installation:
There is a simpler way to fix the installation issue than symlinking the header file into PHP sources. When running pecl install, you can provide additional compile arguments via the CFLAGS environment variable. So, on the Apple Silicon platform, you can use the following command to get the extension to compile:
CFLAGS=-I/opt/homebrew/include pecl install mongodb
Note that this is only necessary on Apple Silicon, not on x64. It also works for other extensions that fail because of similar errors (e.g. apcu)
I had the same issue with PHP 7.3, I solved it just by running the following commands:
cp /opt/homebrew/Cellar/pcre2/10.38/include/pcre2.h /opt/homebrew/Cellar/php#7.3/7.3.31/include/php/ext/pcre/pcre2.h
Then installed it successfully:
sudo pecl install mongodb
I have finally solved my problem. I used PHP 8.1.7 - Mac Pro 2022 - Apple Silicon (M1)
My errors: fatal error: 'pcre2.h' file not found
The solution that I used:
1. brew install pcre2
2. ln -s /opt/homebrew/Cellar/pcre2/10.40/include/pcre2.h /opt/homebrew/Cellar/php/8.1.7/include/php/ext/pcre/pcre2.h
Please check your path again when use `ln -s`
3. sudo pecl install mongodb
See more: Install pecl pear on MacOs - Link
Success Installation:
Hope it help you :) Thanks
cp /Applications/MAMP/Library/include/pcre2.h /Applications/MAMP/bin/php/php8.0.8/include/php/ext/pcre/pcre2.h
then run
sudo pecl install mongodb
If you use MAMP,
Based on #Kelwin Tantono's answer follow instructions to install mongodb then,
Firstly, check for the location of pcre2.h file by
cd /opt/homebrew/Cellar/pcre2/
In this directory find the folder with ls command, in my case it was 10.40 .
Change 10.40 value in the below code with the result of ls command.
Then, check your php version with moving to php directory at MAMP by
cd /Applications/MAMP/bin/php/
Change php8.0.8 value in the below code with your desired php version.
cp /opt/homebrew/Cellar/pcre2/10.40/include/pcre2.h /Applications/MAMP/bin/php/php8.0.8/include/php/ext/pcre
Now you can install mongodb extension with below command after changing your working directory to
cd /Applications/MAMP/bin/php/php8.0.8/bin
sudo pecl install mongodb
Now, you should add extension=mongodb.so to php.ini file with
echo "extension=mongodb.so" > /Applications/MAMP/bin/php/php8.0.8/conf/php.ini
Do not forget to change php version.

Apache, PHP 5.6 or 7.0: Library not loaded: openssl/lib/libcrypto.1.0.0.dylib using Homebrew

I am trying to load either PHP 5.6 or PHP 7.0 module in the Apache httpd.conf config file on macOS 10.15 Catalina. But what I receive when starting the Apache server using sudo apachectl start in Terminal is the following error:
httpd: Syntax error on line 187 of /private/etc/apache2/httpd.conf: Cannot load /usr/local/opt/php#5.6/lib/httpd/modules/libphp5.so into server: dlopen(/usr/local/opt/php#5.6/lib/httpd/modules/libphp5.so, 10): Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib\n Referenced from: /usr/local/opt/php#5.6/lib/httpd/modules/libphp5.so\n Reason: image not found
Since PHP versions 5.6, 7.0 and 7.1 have been deprecated and removed from Homebrew, following this guide, I had to use an older deprecated tap and installed both PHP 5.6 and 7.0 by running:
brew tap exolnet/homebrew-deprecated
brew install php#5.6
brew install php#7.0
For the sake of complete information, I have tried both the Apache which comes with macOS and the latest Apache 2.4.43 installed via Homebrew, but this should not make a difference.
So the question is, how can I solve these errors and make PHP 5.6 and 7.0 running on macOS using Homebrew?
The solution is to install an older version of the openssl library. To be more specific, PHP 5.6 and php 7.0 require openssl 1.0.2, which you can install via Homebrew by running the following in Terminal:
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/8b9d6d688f483a0f33fcfc93d433de501b9c3513/Formula/openssl.rb
brew switch openssl 1.0.2t
However, after running the above, when using PHP 5.6, php 7.0 or php 7.1, another "Library not loaded" error might occur., in particular, this one:
httpd: Syntax error on line 183 of /usr/local/etc/httpd/httpd.conf: Cannot load /usr/local/opt/php#5.6/lib/httpd/modules/libphp5.so into server: dlopen(/usr/local/opt/php#5.6/lib/httpd/modules/libphp5.so, 10): Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib\n Referenced from: /usr/local/opt/php#5.6/lib/httpd/modules/libphp5.so\n Reason: image not found
Here, another older library is required, icu4C in this case. The solution is to run the following:
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/a806a621ed3722fb580a58000fb274a2f2d86a6d/Formula/icu4c.rb
brew switch icu4c 64.2
Note for switching to PHP 7.2, PHP 7.3 or PHP 7.4
Since PHP 7.2, PHP 7.3 and PHP 7.4 do not work with the above mentioned older, 64.3, version of the icu4c library, whenever you need to switch to these PHP versions, e.g., by using this easy brew PHP switcher script, you also hav to switch the version of the icu4c library by running this command:
brew switch icu4c 67.1
Resources
OpenSSL 1.0.2m on macOS - Stack Overflow.
homebrew-core/openssl.rb at 75b573845a17aaf3f7c84dc58e97cf5fe39a502b ยท Homebrew/homebrew-core.
node.js - dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac - Stack Overflow.
macOS 10.15 Catalina Apache Setup: Multiple PHP Versions | Official home of Grav CMS.

PHP Composer Not Working On Mac

I have installed a bitnami mac stack mainly because I require at least PHP 5.4.7 version for my project. However, I have run into an issue with composer. This is the error I get when I run:
php composer.phar install --dev
The error:
Richard-Knops-MacBook-Pro:my-project richardknop$ php composer.phar install --dev
dyld: Library not loaded: /Applications/MAMP/Library/lib/libiconv.2.dylib
Referenced from: /opt/local/bin/php
Reason: Incompatible library version: php requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0
Trace/BPT trap
Richard-Knops-MacBook-Pro:my-project richardknop$
How to solve it?
Update your mamp installation the error clearly says that your libiconv.2.dylib is outdated.
If MAMP has no more-to-date version install apache + php via. mac-ports.
BitNami is self-contained and doesn't modify your system environment. I think that the problem was that the BitNami environment was not loaded.
Referenced from: /opt/local/bin/php
That doesn't seem to belong to a BitNami installation. For future reference the solution (I think) would have been:
Load the BitNami environment executing /Application/mampstack-5.4.x/use_mampstack
After that make sure that the environment is loaded correctly executing which php
Then execute php composer.phar install --dev

Categories