How to update Laravel Installer "laravel/installer" to latest version? - php

I tried to update my laravel/installer using the command:
composer global update laravel/installer
But it only upgraded its minor version (assuming that it uses Semantic Versioning).
Package operations: 0 installs, 1 update, 0 removals
- Updating laravel/installer (v2.1.0 => v2.3.0): Downloading (100%)
Then I execute the update command again:
composer global update laravel/installer
But outputs:
Nothing to install or update
I now uses PHP 7.4.4 (cli) obtained using php -v so I assume that it should be able to upgrade to latest which is Laravel Installer 3.0.1.

If running composer global update laravel/installer is not enough to upgrade the the desired version, there might be package dependencies that restricts the upgrade to the latest.
I do not know if there is a composer option to do that on global scope but the following commands works for me:
# uninstall the package
composer global remove laravel/installer
# reinstall
composer global require laravel/installer
The 1st process outputs the outdated packages dependencies that are removed with the laravel/installer package.
Then the 2nd process installs the latest laravel/installer with the updates dependencies.
Laravel documentation does not include how to update the installer package yet.
Update: Adding Documentation link on how to update a composer package.
composer require specific version documentation.
php composer.phar require "vendor/package:2.*" vendor/package2:dev-master
As we can see, specific version could be supplied after the colon.
https://getcomposer.org/doc/03-cli.md#require

your php version is restricting it.
it's probably because you have multiple PHP versions installed.
update your environment variable of PHP.
then remove The Laravel installer and install it again.

Related

Laravel globally installs 4.1.1 instead of 8.0.1

I am trying to install laravel 8 globally but it is installing version 4.1.1 every time. I use this code:
composer global require laravel/installer
Then i check version by writing this:
laravel -V
How can i install the latest version?
Note: it only happens when i install it globally
When you run composer global require laravel/installer it installs the Laravel Installer globally. The installers latest release is 4.1.1 - see Github releases
To create a new Laravel 8 project you need to run
$ laravel new example-app
after you installed the installer. Find these steps in the Laravel docs.
Determine the version
Option 1
Run php artisan --version in your folder where you installed your project.
Option 2
After you created your project you can go into the folder where you installed it, f. ex. example-app, and chech the file composer.json.
There you can find a require section with the packages laravel/framework telling you the correct version.
{
// ... other stuff
"require": {
// ... other packages
"laravel/framework": "^8.12",
}
}
You probably need to familiarize yourself with Composer and how package management works.

Why do I get a laravel error while creating a new project?

When I type laravel new blog I get the following error.
In RequestException.php line 113:
Server error: GET http://cabinet.laravel.com/latest.zip resulted in a 522 Origin Connection Time-out response:
<html>
<head><title>522 Origin Connection Time-out</title></head>
<body bgcolor="white">
<center><h1>522 Origin Conne (truncated...)
Is the same error if I typ composer create-project --prefer-dist laravel/laravel blog.
And the link doesn't work if I try to go there.
Your Laravel installer is very out of date. The only way to get the latest version is to remove and install again:
composer global remove laravel/installer
composer global require laravel/installer
You need to update the installer to the latest version.
laravel-news.com/updating-the-laravel-installer
composer global require "laravel/installer:^4.0"
after update you check your version using: laravel --version and you should get output like Laravel Installer 4.0.3
try to update laravel/installer globally via:
composer global update laravel/installer
if it didn't work then you can try to remove and install it again:
composer global remove laravel/installer
composer global require laravel/installer
Check your PHP version:
php --version
It has to be >=7.3. If it isn't you have to upgrade your PHP version.
You can download the latest stable version here
If none of the above works, try this:
composer create-project --prefer-dist laravel/laravel name of your project
The simplest way to update to the next major version of the installer is via composer require to globally require it:
composer global require "laravel/installer:^4.0"
Worked for me.
Do this:
composer create-project laravel/laravel example-app
if the following fails:
composer global remove laravel/installer
composer global require laravel/installer
The latest Laravel installer will be essential to your workflow which includes support for Jetstream.
The new version also uses composer create-project behind the scenes instead of downloading an archive from Laravel’s build servers.
Update the latest version of laravel/installer with any of the following approaches:
Update to ^4.0 via composer require
composer global require "laravel/installer:^4.0"
Uninstall and Re-install the package via Composer
composer global remove laravel/installer
composer global require laravel/installer
Update the global composer.json file and run composer update
{
"require": {
"laravel/installer": "^4.0",
} }
composer global update
Verifying the Update
laravel --version
Click here to know more about updating the Laravel Installer
Am putting this issue here it may help somebody. I was using Ubuntu 20.04 and this is my approach.
i installed an older version of laravel using the command below.
composer global require "laravel/installer=~1.1"
this fixed my $PATH
keep in mind that this installs an older version of laravel.
After all the above i removed the laravel using the command below
composer global remove laravel/installer
then re-installed it using the command below
composer global require laravel/installer
With all this done you should be running your laravel just fine plus it will be up-to-date.
The workaround of this problem is getting latest version of Laravel Installer as per New Laravel Installer via composer global require "laravel/installer:^4.0"
verify the version using $ laravel -v
It should return "Laravel Installer 4.1.0"
If you use laravel homestead, maybe you should update the box itself.
Dont forget to backup your databases.
From the directory where Homestead is installed, run the update command:
vagrant box update
vagrant destroy
vagrant up
For a more detailed description, see: How to update your Laravel Homestead Box
You can run this command for install requirements of laravel installer with laravel installer:
$ composer global require laravel/installer -W
update your composer in case you have an older version by running this command composer self-update
then run this command composer global require laravel/installer to update the laravel installer.
happy coding.
Another issue I was having is that my env variable for Composer\vendor\bin was stored within a windows.old folder and I could not find username/AppData in the normal place. Make sure you show all hidden folders and select the bin folder from the right root folders.
Just try this:
It will definitely work
composer create-project laravel/laravel project_name
I had similar problem, and although I had tried this :composer create-project laravel/laravel {directory} 4.2 --prefer-dist
What I realised is that the above command is that it would only temporarily resolve the issue ,with regard specifically to the new project that you have created.But it would not resolve for your other new projects.
The correct commands to resolve your problem completely are these two:-
composer global remove laravel/installer
composer global require laravel/installer
What I realised is that you can copy-paste the two commands at the same time,but you will need to click enter button after the "remove command " {first command } has finished, so that the second command can run...remember.
After leaving the two to successfully complete, use the command,laravel -v, e.g C:\xampp\php>laravel -v , to check your update version of the laravel installer.You should be able to see something like :Laravel Installer 4.2.8
Thanks to these commands my issue was resolved.

How to downgrade or install a specific version of Composer?

I'm getting the following error in a project I'm setting up:
You are using Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report a plugin-issue to ask them to support Composer 2.
I've started at a new company this week, just trying to get their projects installed and there doesn't seem to be a way to change my composer version on Windows. I'd rather not update all their packages as I'm not familiar with the projects yet and have no clue what kind of implications go into that.
Assuming a regular composer installation, to rollback to version 1 of composer, you simply execute:
composer self-update --1
When you want to go back to version 2 (which you should, after updating or removing the incompatible plugins):
composer self-update --2
The above will take you to the latest on any of the two major versions.
You can also "update" to a specific version just by passing the version number to self-update:
composer self-update 1.10.12
composer self-update 2.0.7
After performing any self-update, you can specify --rollback to go back to the previously installed version.
composer self-update
composer self-update --rollback
Finally, if you are feeling adventurous, you can update to a pre-release version by executing:
composer self-update --preview
If you have already installed composer on your system. then paste the below code to downgrade the composer version with a specific version as per your need.
composer self-update 1.10.14
for ubuntu system use the below command
sudo -H composer self-update 1.10.14
Just two commands worked for me. Currently I have composer 2.x.x , I had 1.10.x . First one command will download downgrade version and then second command will rollback to 1.x.x
php composer self-update --1
composer self-update --rollback
I found a flag in composer installer "--1" and "--2".
I'm using this command inside of my Dockerfile:
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --1
You can use following code for update to specific versions
composer self-update 1.10.12
composer self-update 2.0.7
or
composer self-update --1 or 2
The below command is used to update the specific version of the composer.
composer self-update [version no of composer]
Use phar instead.
Download specific version of composer.phar file from :
https://getcomposer.org/download
Place this phar file in your project root directory where you are trying to run composer install/update/require
now instead of composer require use php composer.phar require

installing a laravel package using composer without updating dependencies [duplicate]

This question already has answers here:
Composer: how can I install another dependency without updating old ones?
(5 answers)
Closed 2 years ago.
I want to install zizaco/entrust package in laravel 5.8, in their github page it was said to include "zizaco/entrust": "5.2.x-dev" in composer.json file and run composer update command. I did so as below and ran composer update command.
"require" : {
"php" : "^7.1.3",
"fideloper/proxy" : "^4.0",
"laravel/framework" : "5.8.*",
"laravel/tinker" : "^1.0",
"laravel/ui" : "^1.2",
"maatwebsite/excel" : "^3.1",
"zizaco/entrust" : "5.2.x-dev"
},
but composer update command updates all packages to latest versions (these packages i included in "require" field as above) when installing zizaco/entrust package. So is if there are some coding faults in latest updated packages then whole site can break. FYI after i run the above command i see local git showing changes in many files in folders under vendor folder, it means that there are some updates in packages right?. so it's recommended that composer install command should be run so that those dependency packages will not be updated to latest versions.
So, in my case after including "zizaco/entrust": "5.2.x-dev" in require field in composer.json as above, if i run composer install then it don't install zizaco/entrust package. Furthermore, if i run composer require zizaco/entrust 5.2.x-dev then it still installs latest versions of dependency packages.
So how do i prevent installing latest versions of dependency packages i included in "require" field in composer.json file and i only install zizaco/entrust package.
So that my laravel 5.8 site don't break for updating any packages to latest versions because of malfunction codes or whatever in latest versions. It's very important to handle this scenario because we need to install packages in laravel site for various needs.
You've got two options: use composer require to specify the package to install, or manually update your composer.json file and use composer update [package].
Composer Require
composer require zizaco/entrust:5.2.x-dev
This will automatically update your composer.json file and install the specified version. This will not update any of your other dependencies. While the documentation specifies the package and version should be separated by a colon (:), I tested it with a space and it seemed to work.
Composer Update [package]
composer update zizaco/entrust
If you have manually updated your composer.json file, you will need to run composer update and specify the package to update. If you specify a package to update, only that package will be affected. When you don't specify the package to update, composer will look for updates for all packages.
A Note On Composer Install
composer install will not help you here. If you already have a composer.lock file (which you will since you're just attempting to add a new package), composer install will only look at your composer.lock file and attempt to install everything that is defined there. That means, if you manually update your composer.json file, and run composer install, it will not install the new requirement you specified.
Only when you don't already have a composer.lock file will composer install attempt to resolve dependencies and install them.
Run composer install instead. Alternatively you could use composer require <package name>.
Composer install looks in your composer.lock for exact versions, and only in composer.json for packages that are missing.
Composer update will look in composer.json for version constraint which roughly means "a range of versions". This is why different versions are getting installed.
Step 1:
You just need to add your package to the composer.json file and run the command:
composer install
composer install will check for the new package and install that, besides that it will check for any deprecation in other packages.
Step 2:
You can directly run your command in composer
composer require package/name
For example, if I need to install firebase, run below command from the project root:
composer require firebase/php-jwt
Installing new packages from the terminal automatically adds it into the composer.json file and it does not update previously installed packages.
Hope this helps!!

Composer require gives errors while installing barryvdh/laravel-dompdf

I'm quite new with Laravel and wrote my first app.
I'm using Laravel 5.4 with PHP 7.1.5 on Windows, but when I run the composer require barryvdh/laravel-dompdf command, I get following issues. I have followed many "possible solutions" but still it is not working.
This is the error:
Your requirements could not be resolved to an installable set of
packages.
Problem 1
- Installation request for barryvdh/laravel-dompdf ^0.8.1 -> satisfiable by barryvdh/laravel-dom
pdf[v0.8.1].
- barryvdh/laravel-dompdf v0.8.1 requires dompdf/dompdf ^0.8 -> satisfiable by dompdf/dompdf[v0.
8.0, v0.8.1, v0.8.2] but these conflict with your requirements or minimum-stability.
Don't composer update. If you have dompdf/dompdf in your composer.json just update it, specifying 0.8.* as version and running
composer update dompdf/dompdf
then
composer require barryvdh/laravel-dompdf
--
Running a generic composer update will affect all your other dependencies you may want keep as they currently are.
All the changes affected by your composer update command are then recorded in your composer.lock file.
When you'll move your project somewhere else or you'll deploy it on a server for example, the composer install command will read the composer.lock file and will install the exact version of your dependencies which are recorded in it. So you'll be sure about the version of your dependencies.
Run this command
composer require barryvdh/laravel-dompdf "^0.8.2" .
Delete your composer.lock file and run:
composer install
Check then dompdf/dompdf may updated e.g. 0.7.* or ~0.7.0
composer update;
composer require barryvdh/laravel-dompdf;

Categories