When I create a new Laravel project, the browser displays an error 500. I found this in the log:
PHP Parse error: syntax error, unexpected '?' in vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 233
the code in 233 is:
return app('cache')->get($arguments[0], $arguments[1] ?? null);
But as i know, null coalescing operator( ?? ) is supported from PHP 7.0
My PHP Version:
PHP 7.1.8-2+ubuntu14.04.1+deb.sury.org+4 (cli) (built: Aug 4 2017 14:34:05) ( 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+ubuntu14.04.1+deb.sury.org+4, Copyright (c) 1999-2017, by Zend Technologies
Laravel Version: 5.5.0
Who knows what happened?
If I had to guess, I'd say you installed the PPA 7.1.8 as CLI only (php7-cli). You're getting your version info from that, but your libapache2-mod-php package is still 14.04 main which is 5.6. Check your phpinfo in your browser to confirm the version. You might also consider migrating to Ubuntu 16.04 to get PHP 7.0 in main.
I had approximately the same problem with Laravel 5.5 on ubuntu, finally i've found a solution here to switch between the versions of php used by apache :
sudo a2dismod php5
sudo a2enmod php7.1
sudo service apache2 restart
and it works
If you came across this error while using the command line its because you must be using php 7 to execute whatever it is you are trying to execute. What happened is that the code is trying to use an operator thats only available in php7+ and is causing a syntax error.
If you already have php 7+ on your computer try pointing the command line to the higher version of php you want to use.
export PATH=/usr/local/[php-7-folder]/bin/:$PATH
Here is the exact location that worked based off of my setup for reference:
export PATH=/usr/local/php5-7.1.4-20170506-100436/bin/:$PATH
The operator thats actually caused the break is the "null coalesce operator" you can read more about it here:
php7 New Operators
If you have newly upgraded your php version you might be forget to restart your webserver service.
I had the same error and the problem is that I had not correctly installed Composer.
I am using Windows and I installed Composer-Setup.exe from getcomposer.org and when you have more than one version of PHP installed you must select the version that you are running at this point of the installation
I had the same problem with the laravel initiation. The solution was as follows.
1st - I checked the version of my PHP. That it was 5.6 would soon give problem with the laravel.
2nd - I changed the version of my PHP to PHP 7.1.1. ATTENTION, in my case I changed my environment variable that was getting Xampp's PHP version 5.6 I changed to 7.1.1 for laragon.
3rd - I went to the terminal / console and navigated to my folder where my project was and typed the following command: php artisan serves.
And it worked! In my case it started at the port: 8000 see example below.
C: \ laragon \ www \ first> php artisan serves
Laravel development server started: http://127.0.0.1:8000
I hope I helped someone who has been through the same problem as me.
I had similar kind of problem. It looked like this:
Null coalescing operator( ?? ) is not supported by my version of PHP. As I had no option to upgrade the version, I wrote something like this: {{ $product->price ? $product->price:'' }} instead of {{ $product->price ?? '' }} and it solved the problem.
Related
I'm trying to get a code igniter (PHP) site working on Elasticbeanstalk using apache. When i run it php 5.6(EB stack), everything works fine, but when using Php 7.4, i get the following error:
/var/www/html/.htaccess: <IfModule not allowed here
I also tried using .ebextensions to override the Allowoverrride All but using that php code is displayed in browser rather executing it.
My EB Stack is :- PHP 7.4 running on 64bit Amazon Linux 2/3.1.0
Note: When i am running the same code in php 5.6 in elastic beanstalk it's working fine
7.4 will definitely be supported, and I would assume on release. No release date specified - but not long!
I've modified the php.ini file to enable opcode caching and restarted apache but it is nowhere in sight with phpinfo(). php -v says:
PHP 7.4.1 (cli) (built: Dec 18 2019 14:46:18) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
Most other examples I see form this command say something like "with Zend Opcache".
No other .ini files except the one at /usr/local/etc/php/7.4/php.ini are being used, according to php.
I tried installing zend opcache with pecl but that says it's for versions 5.2.0 thru 5.5.0.
Searched through google for 30 min. but not getting anywhere.
OK, got it. Searched for the opcache.so file in Finder and added it's path to php.ini:
zend_extension=/usr/local/Cellar/php/7.4.1/lib/php/20190902/opcache.so
I'm trying to install the commerce module in Drupal 8 however I get the error 'BC math PHP extension not found'.
I've searched for this problem and tried different things such as editing the PHP.ini by adding 'bcmath.scale=2' however I still get the error message.
Any help would be appreciated, thanks.
Just install bcmath plugin for your php version with no need to (re)build php as mentioned on accepted answer
# get php version
php -v
# install bcmath based on your version lets assume php 7.1
# for ubuntu
sudo apt install php7.1-bcmath
# for centos
yum install bcmath
# restart apache
sudo systemctl restart apache2
Above problem appears when installing commerce or commerce kickstart using composer
Update 2020
Please refer to #GiorgosK's answer for installing bcmath via a package manager if you are using a distribution that provides a bcmath package for PHP. I will ask the OP in comments to update the recommended answer, since that solution is probably what most people need.
Three years ago when I answered this question, I suggested that you have to rebuild PHP to get bcmath. That was incorrect. I was using an older distribution of Debian/Ubuntu that provided bcmath as a statically linked extension in the core php package. I determined at the time (incorrectly) that bcmath was a core extension that had to be enabled at build-time (like SPL and PCRE).
For those trying to troubleshoot a missing bcmath extension (such as those building/installing PHP themselves or nevertheless encountering issues), I've corrected and updated my original answer below. It explains in detail how to troubleshoot a missing PHP extension.
Original Answer (Corrected)
The error message indicates that PHP wasn't built with bcmath support or can't find the installed extension. PHP extensions are either built into PHP directly or they are loaded from an external dynamic library file at runtime.
Since PHP obviously doesn't have the extension built-in, it can't find the external library file that provides bcmath. This file on POSIX platforms will be called bcmath.so and php_bcmath.dll on Windows.
Extension files are installed under a directory indicated by the extension_dir property in php.ini. To determine the value of this property, run the following command:
php -r 'echo ini_get("extension_dir").PHP_EOL;'
The default value for this property is configured when PHP is built and may vary from distribution-to-distribution.
Once you verify the extension file is installed in this location, you can then check to see if the extension is enabled in php.ini. You should see a line that enables the extension like so:
# POSIX platforms
extension=bcmath.so
# Windows
extension=php_bcmath.dll
For Linux distributions like Ubuntu/Debian that install extensions via the package manager, the format is somewhat different since Debian employs a distributed configuration. Typically the package manager installs everything correctly, but you can check to see if an ini file exists for bcmath under the corresponding conf.d directory. These small ini files are snippets imported into the larger php.ini file, and they are typically symlinked to /etc/phpX/mods-available, allowing modules to be initially enabled for all PHP SAPIs such as CLI, CGI, Apache Mod PHP, ETC. Make sure a symlink exists for the PHP SAPI you need to use.
To ensure your PHP is loading the extension, run phpinfo(); in a test page and search for bcmath. You can also more easily do this with the CLI using a command like:
$ php -i | grep -i bcmath
# Success output: BCMath support => enabled
# (Another command that works well for checking extensions)
$ php -m | grep -i bcmath
# Success output: bcmath
In order for the CLI to show accurate results, it must target the same php.ini file. If it doesn't, then use the -c option to temporarily point the CLI at the correct php.ini (i.e. the one being used by your Drupal site).
Add BC MATH extension for PHP 7.2
If you are getting this (https://prnt.sc/sehmd5) error then, run below command using vagrant ssh
Run these command in root of vagrant ssh
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php7.2-bcmath
service apache2 restart
Then open php.ini and search for bcmath
If bcmath scale is 0, Change it to 2
Restart php
Restart Apache
Hard Reload website
Install required modules
Similarly for any version of PHP, you only need to change PHP version in 3rd command.
I am trying to follow the directions on this ud3323/bpm wiki page to create an Ember.js application using bpm. The very first command on this page (bpm init hello_world) is throwing an exception - "No such file or directory - C:/apps/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/execjs-1.2.13/lib/execjs/support/which.bat" (see the issue logged here - my comment is the second one). I checked the files under execjs directory - there is no file called which.bat. Note that I installed bpm using "gem install bpm". I don't know how to build ud3323's fork (don't know Ruby - I installed it just to try out bpm). Can anybody help me get past this issue?
Thanks in advance for your time.
Naresh,
I got some free time and found the issue. The current build of BPM requires the use of the gem execjs version 1.2.4. You probably have the latest version which is 1.3.0 or the latest from the 1.2.x branch.
What you need to do is install the correct version by running the command gem install execjs --version 1.2.4. After that BPM should work fine. I have it running on Windows7 64bit with a clean installation of Ruby 1.9.2.
Also for anyone else, I have detailed instructions of exactly what I did on this page: https://github.com/ud3323/bpm/wiki/Installing-with-Windows
I get this error with a fresh Sitecore 6.4 install.
HTTP Error 500.21 - Internal Server Error Handler
"AboMapperCustom-88978986" has a bad module "IsapiModule" in its
module list
Any ideas? AppPool is integreated but i get same error on classic.
There is a problem with the installer it sets up the appPool using .net 2.0. If you switch it to use .net 4.0 and make sure it's in integrated mode, you should be good to go.
I was using Windows 7 and Sitecore 7.5. This solved the HTTP Error 500.21 for me:
Run the command prompt as administrator.
Go to this directory: %windir%\Microsoft.NET\Framework\v4.0.30319\
And run the command: aspnet_regiis -i
Hope this can help.