The problem:
I have installed Composer and followed the Quick start guide in the Laravel 4 documentation.
I get the following error when I run composer install or composer update:
Script php artisan optimize handling the post-install-cmd event
returned with an error...
I tried to run the following composer command:
composer create-project laravel/laravel myproject --prefer-dist
Or use their laravel.phar:
laravel new myproject
Or get the zip version from git: https://github.com/laravel/laravel?source=c
And I still fail to update via composer.
Additional information:
My PHP version on my Mac is:
PHP 5.4.17 (cli) (built: Aug 25 2013 02:03:38)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0,
Copyright (c) 1998-2013 Zend Technologies
PHP version on MAMP: 5.4.10
I found some solutions on Google / Stack Overflow but those did not work well in my case.
It says:
MCrypt PHP extension required
So it looks like you're missing the Mcrypt extension, which is required by Laravel (actually, I think it's used only by the Authentication class for password handling, not for the rest of the components of the framework).
I haven't got a Mac, but the command to install it should be something like this, using Homebrew
brew tap josegonzalez/php
brew install mcrypt php54-mcrypt
These links might help you:
http://www.jorble.com/2013/04/install-php-mcrypt-in-macosx/
http://coolestguidesontheplanet.com/install-mcrypt-php-mac-osx-10-9-mavericks-development-server/
Having the setting xdebug.scream = 1 in the configuration was the cause of the problem for me. I fixed it by doing the following:
Find XDebug configuration file.
$ sudo find / -name xdebug.ini
Edit file using any text editor.
$ sudo vi /your_path/xdebug.ini
Set xdebug.scream = 0
Reload the server (Apache/Nginx/whatever).
$ sudo service nginx reload
You might have Mcrypt installed already on your computer, if you are using MAMP or any other application. So, you don't need to install Mcrypt again. Add the following code to a php file and place it in your htdocs directory. See the info about the PHP you are running. You can see whether Mcrypt is already installed or not.
<?php
phpinfo();
If it shows Mcript, then do the following:
Check which PHP version you are using. You can see different directories for different PHP versions in this directory: /Applications/MAMP/bin/php/.
Move to the user's home directory. Use this command on terminal: cd ~.
Edit (or create a new one if not exists) .bash_profile file.
Add the following line:
where php5.5.10 is the directory of the PHP version you are using.
export PATH=/Applications/MAMP/bin/php/php5.5.10/bin:$PATH
Now restart your computer. And you can use php artisan command of Laravel.
Source of information: Laravel requires the Mcrypt PHP extension
Related
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.
Mainly after to install composer for windows 10 my wamp didn't work anymore.
I explain that I tried in order to workaround this issue:
I tried to find my answer but there I didn't get:
Delete another versions: I read this question, My wampserver has assigned the correct version, and I don't want to delete my another versions.
Install Composer manually: I tried to install the composer manually but the problem persist, I don't know if there is something pending to do wamp server side.
This is the content of the my composer.bat file:
#echo OFF
:: in case DelayedExpansion is on and a path contains !
setlocal DISABLEDELAYEDEXPANSION
#C:\wamp\bin\php\php5.6.38\php.exe "%~dp0composer.phar" %*
This is the wamp server error that I have:
There is an error.
There is Wampserver path (c:/wamp)
into Windows PATH environnement variable: (C:\wamp\bin\php\php5.6.38)
It seems that a PHP installation is declared in the environment variable PATH C:\wamp\bin\php\php5.6.38
Wampserver does not use, modify or require the PATH environment variable.
Using a PATH on Wampserver or PHP version
is detrimental to the proper functioning of Wampserver.
I add the image that I can see on wamp server icon:
Message of wampserver
I'll republish my solution here, because I think it solves your problem perfectly and it is not so adequate to the question where it was posted. I hope it will help other people
TL; DR
In Windows 10, you can have Composer without producing an error in Wampserver if you install it on the Windows Subsystem for Linux (WSL) environment.
Install PHP on WSL
Then install Composer on WSL
Additional note:
Please, keep in mind that if your project needs an additional PHP extension, you will have to install it in the WSL side.
Then, enable the extension in the php.ini file located in the folder /etc/php/YOUR_PHP_VERSION with the command:
sudo nano /etc/php/YOUR_PHP_VERSION/php.ini
The problem
In Windows, Composer requires to set the system variable PATH to work properly during the installation; it doesn't matter if it is installed globally using the Windows Installer or locally, following this procedure
However, inserting the executable PHP file location in PATH causes an error in Wampserver, the ERROR C:/wamp64 or PHP in path. You can see the error message if you left-click on the Wampserver icon in the notifications area of the task bar.
Although Wampserver may work as usual, it could eventually fail according to the answer to this question on the official Wampserver forum:
Wampserver does not create paths in PATH system environment variable.
Wampserver does not use PATH system environment variable.
Some content - paths to PHP or mysql versions - of the PATH system environment variable can create Wampserver malfunctions because PHP configuration files (php.ini) or MySQL (my.ini) are searched first in the paths indicated by the contents of the PATH environment variables before being searched in the Apache, PHP or MySQL folders.
That is why, with version 3.1.3, the content of the PATH environment variable is checked and you are notified if there is a problem.
If your Wamperserver installation suffers already of this error, then
follow the advice from the Wampserver forum,
back up the content of your www folder,
uninstall Wampserver,
reinstall Wampserver.
If you have Windows 10 and followed the previous steps, then you are ready to implement the solution I propose.
The solution
The only solution I found in my research was explained in this tutorial by Jeff Geerling. My answer follows this tutorial in a somewhat loose way.
My starting point
These were the settings of my PC when I began this procedure:
Windows 10 Home Edition 64-bit
WampServer Version 3.1.3 64bit, reinstalled and with no errors
Windows Subsystem for Linux (WSL) Ubuntu installed
Visual Studio Code as text editor, with WSL bash as default integrated terminal
Although Visual Studio with the WSL integrated terminal is not strictly necessary, I had it set because I intended to install and use Composer with it.
1 - Install PHP on WSL
To work correctly, Composer needs PHP but WSL does not come installed with it. So it is necessary to install PHP in this enviroment. According to this answer in AskUbuntu.com, the easiest way to install PHP on WSL is adding Ondřej Surý's PPA. In the Visual Studio Code WSL integrated terminal, type:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
Test that PHP was installed correctly typing php --version. If PHP was installed correctly, the terminal will return a message like:
PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.10-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies
2 - Install Composer on WSL
There are two ways to do it:
The easier one: just type on the integrated terminal sudo apt-get install composer and that will be it.
The second one, and a better approach in my opinion: go to the Composer download page and get the installation code:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
Warning: Do NOT copy/paste the code provided in this tutorial to install Composer. According to the Composer download page, the installation code
will change with every version of the installer.
The best practice here is to get the installation code directly from the download page.
I think this method is a better approach because, with the given code, it is possible to verify the SHA384 of the file and make sure it has not been tampered with.
If you installed Composer through the installation code from the developer website, in order to put that file into the global path on WSL, move the composer.phar file into the /user/bin/local folder with the bash command:
sudo mv composer.phar /user/bin/local/composer
If you installed Composer with the first command, this last step won't be necessary.
To check that the software was installed correctly, type composer on the integrated terminal. You should view a list of composer calling options and available commands.
Keep in mind that, to use Composer, you will need to type the commands in the WSL terminal.
I'm using Mojave OS X and I've been following these steps to install Xdebug through Pecl. I'm trying to set it up so I can use the debugger of PHPStorm.
http://www.devinbaldwin.com/2018/09/27/how-to-install-xdebug-on-a-new-mac-including-mojave/
This is my current setup:
Xdebug installed: no
Server API: Command Line Interface
Windows: no
Zend Server: no
PHP Version: 7.3.6
Zend API nr: 320180731
PHP API nr: 20180731
Debug Build: no
Thread Safe Build: no
OPcache Loaded: yes
Configuration File Path: /usr/local/etc/php/7.3
Configuration File: /usr/local/etc/php/7.3/php.ini
Extensions directory: /usr/local/lib/php/pecl/20180731
I've followed all the steps but got stuck at installing Xdebug because I didn't have phpize.
I've installed the newest version of Xcode to create phpize, this worked at first, but I was having trouble appending the php.ini through PHPStorm because the file was read-only and I've thought of following another guide which talks about downgrading PHP to version 7.2 and installing Xdebug through that version, which is how this problem started.
When I tried to install Xdebug through Pecl, I've got this error.
downloading xdebug-2.7.2.tgz ...
Starting to download xdebug-2.7.2.tgz (230,987 bytes)
.................................................done: 230,987 bytes
69 source files, building
running: phpize7.2
sh: phpize7.2: command not found
ERROR: 'phpize' failed
At the sh, it never showed phpize7.2 before, it used to show phpize without the numbers.
I've tried to uninstall and reinstall homebrew and remove all php versions and installed the current php version as posted above.
I just want to know how I can revert phpsize to the current version. I've tried using PHP 7.2 but I still got the same error.
I've tried this guide since I'm using the latest PHP version, which is 7.3.
https://sys.cuquejo.org/install-php-7-3-xdebug-on-macos-mojave-with-homebrew/
But I still get the same error.
In addition, when I typed phpsize I got this:
Cannot find config.m4.
Make sure that you run '/usr/local/bin/phpize' in the top level
source directory of the module
However, when I typed phpsize --help
Usage: /usr/local/bin/phpize [--clean|--help|--version|-v]
Typing phpize72 --help would only show this:
-bash: phpize7.2: command not found
I'm not sure why this happened but any explanations could help.
I am new on this editor and I would like to try it for php project.
I am trying to configure this package php-integrator-base in my atom ide, but I have this error:
The socket connection with the PHP server could not be established.
This means the PHP server could not be spawned. This is most likely an
issue with your setup, such as your PHP binary not being found, an
extension missing on your system, ...
This is my setup for this package:
This my php verion on my ubuntu distrib:
Anyone else have the same issue with this package ? Where am I wrong ?
EDIT
Since I have make the update of the package today I always have the same error but another one occured.
Indeed, an error message appears to notice that:
Core installed failed
When I start the atom editor I have this message too:
If you are on Unix system then go to :
cd $HOME/.atom/packages/php-integrator-base/core/
then you should have a directory with num version as name like 2.X.X. So :
cd 2.1.0 and ../composer.phar install
I am relevantly new to this IDE as well and had errors with installation of php-integrator-base. I am using Windows and it turned out that it was an issue with my environmental path. Try the following steps:
Add your Git binary path to your environmental path
Enable sqlite on your php.ini file by adding these: extension=php_sqlite3.dll and extension=php_pdo_sqlite.dll
If above steps do not work, try posting an issue at their GitHub repo.
There is a better solution, which solves this "identified" issue and others only visible when running Atom in --dev mode.
Sadly nobody ever pointed to the fact (or noticed) this issue is caused by packages differences in between PHP 7.0 and PHP 7.1. For some reason, for PHP 7.1 some packages still reference items related to PHP5.6, while some other packages are expecting everything to be PHP 7.x related.
The solution is to upgrade the PHP 7.0x to PHP 7.1.
In Ubuntu environments you can do that by running these commands:
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt remove php7.0 (optional, only if you want to uninstall PHP7.0)
sudo apt install php7.1
Simply restart Apache by running:
sudo service apache2 restart
Then check your PHP version to confirm it has been upgraded:
php -v
You should get an output like this:
PHP 7.1.8-2+ubuntu16.04.1+deb.sury.org+4 (cli) (built: Aug 4 2017 13:04:12) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.8-2+ubuntu16.04.1+deb.sury.org+4, Copyright
(c) 1999-2017, by Zend Technologies
You may have to re-enable some extensions after upgrading to PHP 7.1. Atom may complain about these in specific (mbString, SQLite and DOM). Simply run these commands to install/activate them:
sudo apt install php7.1-mbstring
sudo apt install php7.1-sqlite
sudo apt install php7.1-xml
Don't forget to reactivate your old extensions as well (if any). For PHP 7.1 in most cases it is the same "command" just changing "php7" (or "php") to "php7.1".
Once you are done with PHP, navigate to Atom's PHP Integrator folder and check if the folder "3.0.0" exist:
.atom/packages/php-integrator-base/core/3.0.0/
If it doesn't exist go to https://gitlab.com/php-integrator/core/tree/3.0.0, download it and extract the contents of the compressed file in the 3.0.0 folder (you may have to create it):
Then, from inside .atom/packages/php-integrator-base/core/ you run:
composer install
Now, finally, Composer will be able to find the right packages and install all required dependencies.
Simply say "good bye" to the PHP Integrator errors that have been haunting you lately and enjoy your Atom, once again fully functional as it should be.
I hope it helps some fellow friends stop wasting time with lots of proposed solutions that exist online which in reality won't fix the real core of the problem. ;)
Following #Rei suggestion, I make an issue on theri github repo here.
To solve my problem, I follow step by step a manual installation of the package and then use composer inside the package itself to install the core folder.
If ./composer.phar install fails with a "missing sqlite extension", install php-sqlite extension:
sudo apt-get install php-sqlite3
OK, I have seen many posts about this, and I have spent the entire day working through them to solve this issue, with no success.
I am trying to create a Laravel project. I am using a Mac (Yosemite), which is running PHP 5.5.14. There is also an older version of PHP on the machine. When I try to create a project from the command line using "laravel new projectname", no errors are reported, but the command just creates an empty folder named with the project name. I get the "Crafting application..." and "Application ready! Build something amazing" messages but, again, only an empty folder.
If I try to use this command:
composer create-project laravel/laravel projectname
I get this:
Installing laravel/laravel (v5.0.16)
- Installing laravel/laravel (v5.0.16)
Downloading: 100%
Created project in projectname
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for laravel/framework v5.0.16 -> satisfiable by laravel/framework[v5.0.16].
- laravel/framework v5.0.16 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
In the terminal, if I enter this:
which php
I get: /usr/bin/php
/usr/bin/php -v
I get:
PHP 5.5.14 (cli) (built: Sep 9 2014 19:09:25)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
I used homebrew to install autoconf and mcrypt with this command:
brew install autoconf mcrypt
If I run that command again, I get:
Warning: autoconf-2.69 already installed
Warning: mcrypt-2.6.8 already installed
Since I kept getting the error, I assumed it was installed in the wrong place so, I compiled and installed mcrypt myself using these instructions:
[Install mcrypt php extension][1]. I used PHP version 5.5.14 during the install. Mcrypt was installed in this directory: /usr/lib/php/extensions/no-debug-non-zts-20121212/
I have restarted Apache. I have checked my .bash_profile to make sure /usr/bin is in my Path.
If I create a page with phpinfo() and view it in my browser, I see that mcrypt is listed in the "Module Authors" section of the page. It just lists the names of the people who created the module.
I am stumped. I look forward to any suggestions that people might offer (I really don't want to install a virtual box, or anything like that. Surely, I can get this module installed in the right place!)
Thanks very much!
I got this exact same problem too.
You have to find php.ini for php cli and add extension=mcrypt.so
My system is running LAMPP server with preinstalled PHP. So, here's what I do:
Install mcrypt extension
I tried both:
sudo apt-get install mcrypt
sudo apt-get install php5-mcrypt
Configure php.ini for CLI
Then, edit php.ini located in /opt/lampp/etc/php5/cli/php.ini add extension=mcrypt.so on Dynamic Extension section (anywhere is fine I think). Don't forget to restart your server.
Try using composer to install laravel
Now, you can run whatever method you want to install laravel. I download Laravel 5 manually, unzip, then install using composer install command. I think your command composer create-project laravel/laravel projectname would've run smoothly too.
References:
here
mac users install brew and then enter
brew install php56-mcrypt
in terminal
EDIT
if you get any error using above line then try this command
brew install homebrew/php/php56-mcrypt
Please following the step :
cd /etc/php5/cli/conf.d
ln -s ../../mods-available/mcrypt.ini 20-mcrypt.ini
Worked for me.
For MAC users,
brew install homebrew/php/php56-mcrypt