laravel 5.1 installation issue with php 7.1 , cannot install carbon 2 - laravel-5

composer install error on carbon 1 is deprecated
SO, how can i run my vagrant with laravel 5.1 with carbon 1 and I have try find from stackoverflow and other site but no helps comes up .
every thing is done but shows carbon 1 is deprecated

As per https://carbon.nesbot.com/
You can install Carbon 2:
{
"require": {
"nesbot/carbon": "2.64.0 as 1.39.0"
"kylekatarnls/laravel-carbon-2": "^1.0.0"
}
}
But such an old stack will gives you so much trouble. Laravel 5.1 and PHP 7.1 are both in end of life (no longer maintained). You should upgrade the whole stack. At this point having Carbon 1 would make little difference. If you're fine with having old stuff, no longer matching their documentation, then you can ignore deprecation notices.

Related

PHP Fatal error: Class UpdateHelper\ComposerPlugin contains 2 abstract methods in laravel

I want to install laravel on my windows but getting below error
Using below command install laravel
composer create-project --prefer-dist laravel/laravel:^7.0 learning-app
But getting below error in command prompt after run the composer command
PHP Fatal error: Class UpdateHelper\ComposerPlugin contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (Composer\Plugin\PluginInterface::deactivate, Composer\Plugin\PluginInterface::uninstall) in C:\xampp\htdocs\vendor\kylekatarnls\update-helper\src\UpdateHelper\ComposerPlugin.php on line 11
Trying all the commands like composer update but not getting any success.
My php version PHP 7.3.27
Anyone have idea how to solve then let me know
You're trying to install the laravel framework locked at a version released more than 2 years ago, is there a reason for this?
Also, what is the version of your composer (run composer --version)? If you're at the version 2 try downgrading to v1 and try again with the same command, if you really want the 7.0 version of Laravel (or simply install the newest version of the framework).

inheritance of ArrayAccess: Uncaught ErrorException: Collection::offsetExists($key)

NB: Local server PHP Version 8.1.4, laravel project inside composer.json file have "php": "^7.2.5", version & "laravel/framework": "^7.0"
PHP Fatal error: During inheritance of ArrayAccess: Uncaught ErrorException: Return type of Illuminate\Support\Collection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
error displaying below like this :
That's a php version issue. Upgrade laravel or downgrade PHP. This article covers how to downgrade the PHP version so it matches the Laravel Version.
https://bytexd.com/fix-laravel-return-type-of-illuminatesupportcollectionoffsetexistskey/
in your composer.json update line
"php": "^7.3",
to
"php": "^7.3|^8.1",
and run composer update
You would need to upgrade your Laravel Framework version to at least version 8 and it's dependencies using composer.
Reference: https://laravel.com/docs/8.x/releases
Or if you want to postpone it, you would need to add #[\ReturnTypeWillChange] before declaring every function that throws the error. This is highly not advisable.
P.S. If you updated your PHP version you would have to change the PHP version in composer to the one used, in your case it should be "php": "^8.1.4"
In my case, using a mac, turns out my php version was 8.1 which somehow is not compatible with laravel version 7. Tho most of these answers are correct, but they did not fix my issues. I followed these steps (if brew is installed):
brew unlink php#8.1
brew link php#8.0 or lower
Reference How can I easily switch between PHP versions on Mac OSX?
run "composer update" on your project directory and it will work .

How to convert laravel 7.1.3 projects to run on laravel 8.0.0? [duplicate]

after updating my mac to php 8 laravel app stopped working, this is the error I'm getting:
Deprecated: Method ReflectionParameter::getClass() is deprecated in /Users/.../Sites/.../vendor/laravel/framework/src/Illuminate/Container/Container.php on line 871
Deprecated: Method ReflectionParameter::getClass() is deprecated in /Users/.../Sites/.../vendor/laravel/framework/src/Illuminate/Container/Container.php on line 945
Deprecated: Method ReflectionParameter::getClass() is deprecated in /Users/.../Sites/.../vendor/laravel/framework/src/Illuminate/Container/Container.php on line 871
Deprecated: Method ReflectionParameter::getClass() is deprecated in /Users/.../Sites/.../vendor/laravel/framework/src/Illuminate/Container/Container.php on line 945
I've tried to fix the issue by investigating the code with no luck
THE SOLUTION
As explained here latest version of laravel 6, 7 and 8 has made changes required for php 8. all you have to do is:
1- add php 8 to your composer.json (I've kept v7.4 just in case production server does not support php 8 yet)
"php": "^7.4|^8.0",
2- to run composer update to update your laravel to the latest version
composer update
3- make sure update the following libraries since they exist in all laravel applications
PHP to php:^8.0
Faker to fakerphp/faker:^1.9.1
PHPUnit to phpunit/phpunit:^9.3
4- check for any other library which needs to be updated, contribute if they haven't supported php 8. but you should be good to go with most of the libraries since they have active contributors.
EXPLAINING THE PROBLEM
as described here
PHP 8 introduces several improvements in PHP type systems such as the introduction of Union Types, mixed type, and a few more.
With these changes, certain methods in Reflection API's
ReflectionParameter yield incorrect results.
In PHP 8, the following methods from ReflectionParameter class is
deprecated:
ReflectionParameter::getClass()
ReflectionParameter::isArray()
ReflectionParameter::isCallable()
ReflectionParamter::getType() is the recommended way to replace the
deprecated methods. This method is available in PHP 7.0 and later.
Check your php version in your virtual machine(xampp or server).
php --version
Is that version PHP 8 ? Am I right? That's the cause of the problem:
PHP 8 introduces several improvements in PHP type systems such as the introduction of Union Types, mixed type, and a few more.
With these changes, certain methods in Reflection API's ReflectionParameter yield incorrect results.
In PHP 8, the following methods from ReflectionParameter class is deprecated:
ReflectionParameter::getClass()
ReflectionParameter::isArray()
ReflectionParameter::isCallable()
ReflectionParamter::getType()
Downgrade your php version to 7.4 and your Laravel app works like a charm!
I had similar issue. But I had already run brew update and brew cleanup before I noticed the issue. What I did:
I noticed this error from brew cleanup:
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/node
Target /usr/local/bin/node
already exists. You may want to remove it:
rm '/usr/local/bin/node'
To force the link and overwrite all conflicting files:
brew link --overwrite heroku-node
I ran the commands:
brew link --overwrite composer
composer upgrade
composer update
That's what worked for me
If you're using valet you should do the followings:
Downgrade from php8+ to php7.4 valet isolate php#7.4
Then run composer update using valet valet composer update

Laravel - compact(): Undefined variable: operator in Builder.php

I have PHP version-7.3 installed in my system and Laravel-5.8. When I tried to rub composer install or composer update on an old Project with Laravel-5.4 and PHP Version-5.6.4, I got this error shown below:
In Builder.php line 1229:
compact(): Undefined variable: operator
Script php artisan optimize handling the post-install-cmd event returned with error code 1
Then, when I tried to run the application, I got this error page as shown on the screen:
I tried to run:
php artisan cache:clear
and
composer update
but the problem is still there.
How do I get it resolved?
Thank you.
It looks like this issue was fixed in Laravel 5.5 according to this post: https://github.com/laravel/framework/issues/26936#issuecomment-449479336
Since Laravel 5.4 is no longer supported, your best option might be to upgrade. You can find a list of the currently supported versions here: https://laravel.com/docs/releases
The minimal upgrade that should still fix the error would be 5.4 to 5.5. The instructions can be found here: https://laravel.com/docs/5.5/upgrade#upgrade-5.5.0 (please note that support for 5.5 has also ended, but it might still fix your bug). This would also require you to switch the project to PHP 7.0.0 or greater.
If:
You can't upgrade for whatever business/team related reason and
Are sure that the Homestead box is running the correct version of PHP (7.2 or lower based on the answer given here) and yet
are still getting this error,
explicitly define the PHP version on the Homestead.yaml file. This should be done on the sites property as such (each is a new line, of course):
map: test.appp
/home/vagrant/code/test/public
php: "7.1"

Laravel parse error: syntax error, unexpected T_CLASS, expecting T_STRING or T_VARIABLE

After installing laravel we get an error:
Parse error: syntax error, unexpected T_CLASS, expecting T_STRING or T_VARIABLE or '$' in C:\xampp\htdocs\laravel\public\index.php on line 50
Laravel 5.1 uses the ::class property to get string representations of a fully qualified classname. The error you're seeing is caused by this line
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
This language feature has been introduced in PHP 5.5 which is a requirement of Laravel 5.1. Your installed PHP version is probably older than 5.5. Try to update your PHP binary.
In case you are interested in why ::class is used, take a look at this answer
Same thing happened to me also. I found that web server was using my old PHP version 5. To solve it for me, I did this -
sudo a2dismod php5
sudo a2enmod php7.0
sudo service apache2 restart
Your php version is too low.
Try version 7.0 or later php.
Your PHP version on your Xampp is lower than 5.5.9 as specified in the Laravel 5.1 doc.
Simply uninstall your current Xampp software and download a fresh copy at Apache website with this specification 5.6.12 / PHP 5.6.12 .
Do not forget to collaborate with your host provider to ensure that your hosting account runs the required PHP version (>=5.5.9) during the deployment of your Laravel 5.1 app online.
I was facing the same error but error was in app/User.php line 10.
Actually, line 10 was ok but before line 10 I was missing some php syntax.
After correct the php syntax error It was fixed. So you have to check C:\xampp\htdocs\laravel\public\index.php on line 49 carefully I am sure there is something wrong. Just try to correct. It will be fixed.

Resources