Error downloading a laravel pakage using composer update/require - php

I need to download a package on my server, i'm doing:
php7.4 composer.phar update (the package is already in the composer.json file) / php7.4 composer.phar require bumbummen99/shoppingcart, the first row is:
Using version ^4.2 for bumbummen99/shoppingcart
./composer.json has been updated
but lastly it gives me this error:
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
[RuntimeException]
/home/alvapet/vendor/bumbummen99 does not exist and could not be created.
I've also tried to upload the package via ftp in the vendor directory but it gives me error550: permission denied and i've tried creating the directory bumbummen99 but it gives me the same error.
Composer version 2.0.9

I just tried installing this one and its working fine the command I used was
composer require bumbummen99/shoppingcart
so if you are facing this it can mean either your composer version is causing the problem or its your directory that have the permission problems as stated by Nico Haase in above comment

Related

Error : Composer require symfony/web-server-bundle

I tried to execute a symfony project within a docker container by "php bin/console server:run " but it generate the following error :
"There are no commands defined in the "server" namespace.
You may be looking for a command provided by the "Debug Bundle" which
is currently not installed. Try running "composer require
symfony/debug-bundle --dev". ]"
Then i tried to install this package, but the error persist .
And i tried to install symfony/web-server-bundle package too, but another error display:
"Composer require symfony/web-server-bundle Info from
https://repo.packagist.org: #StandWithUkraine ./composer.json has been
updated Running composer update symfony/web-server-bundle Loading
composer repositories with package information Updating dependencies
Your requirements could not be resolved to an installable set of
packages. Problem 1
- Root composer.json requires symfony/web-server-bundle 6.1.*, found symfony/web-server-bundle[v3.3.0-BETA1, ..., 3.4.x-dev,
v4.0.0-BETA1, ..., 4.4.x-dev] but it does not match the constraint.
Installation failed, reverting ./composer.json and ./composer.lock to
their original content "
The symfony/web-server-bundle is now deprecated.
For a dev environment, you can try installing the Symfony cli https://symfony.com/download. I don't know what docker image you are using, but the doc has instructions for installation on multiple different linux environments.
Then you can use the Symfony local server: https://symfony.com/doc/current/setup/symfony_server.html.
Typically the command to run the server is:
symfony server:start
A side note: when using docker you will also need to expose the port the web server runs the application on if you want to access it.

Laravel command not found. But it is added to my $PATH on Ubuntu

So I know there are alot of simmular issues but none if them are exactly the same,
I want to start my first laravel project but, my terminal tells me command not found,
I installed composer from the website and when I run composer I can see that it works perfectally with no issue, when running composer global require "laravel/installer" I get this in response :
Info from https://repo.packagist.org: #StandWithUkraine
Using version ^4.2 for laravel/installer
./composer.json has been updated
Running composer update laravel/installer
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Generating autoload files
9 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
This tells me that laravel is indeed installed but has not updates but when I run command laravel the response is laravel: command not found,
I have added composer to my $PATH already.
This is why I am posting this issue because all the posts I find says to add composer to your $PATH but mine is already but its still a issue.
PHP is also installed on my machine
I am running linux Ubuntu 22.04 LTS
I'll write the answer here so you can close the question. As #geertjanknapen said in the comment if you can install your project the run
composer create-project laravel/laravel your-app-name
cd /your-app-name
php artisan serve
You must have a local server running also, once you have run php artisan serve then just go to http://127.0.0.1:8000/ and you'll see Laravel's home screen. (NOTE 8000 is the default port, so put yours there if you've changed it).

Fatal Error: composer.lock was created for PHP version 7.4 or higher but the current PHP version is 7.1.33

At the moment, I'm facing this issue. I've tried everything: deleting composer.lock, then updating composer.json, tried to update PHP version to the highest version, still the same. When I check PHP version in CMD, it shows that my version is 7.4.10, but when I try to open "public" folder on localhost, it shows this "Fatal error: composer.lock was created for PHP version 7.4 or higher but the current PHP version is 7.1.33.".
Thanks in advance
Try to delete symfony.lock and composer.lock then deletr vendor folder and launch command composer install

Can't get Composer to work on Windows

I'm trying to use https://github.com/phpWhois/phpWhois in my PHP scripts, but can't get it to work. I'm an absolute beginner when it comes to using Composer.
This is what I tried:
Cloned the git repo locally
Installed Composer for Windows
In Powershell, navigated to the local repository
Typed composer require. Composer first asked me: Search for a package:, where I simply pressed ENTER. Then, Composer installed various packages in the vendor directory (phpunit, symfony, sebastian, etc.), and it created an autoload.php file.
But if I include that autoload.php in my example script (the basic example on the phpWhois Github main page), it generates the following error:
Fatal error: Class 'phpWhois\Whois' not found in /home/myServer/www/myApp/api/whoistest.php on line 12
Well, the Installation manual on the Github page says I should run
php composer.phar require "phpwhois/phpwhois":"~4.0"
So I tried the following in the Powershell console:
composer require "phpwhois/phpwhois":"~4.0"
[UnexpectedValueException]
Could not parse version constraint :~4.0: Invalid version string ":~4.0"
Then this:
composer require "phpwhois/phpwhois"
Problem 1
Conclusion: remove phpwhois/phpwhois dev-master
Can only install one of: phpwhois/phpwhois[dev-master, 4.2.3].
Can only install one of: phpwhois/phpwhois[dev-master, 4.2.4].
Can only install one of: phpwhois/phpwhois[v4.2.5, dev-master].
Installation request for phpwhois/phpwhois dev-master -> satisfiable by phpwhois/phpwhois[dev-master].
Installation request for phpwhois/phpwhois ^4.2 -> satisfiable by phpwhois/phpwhois[4.2.3, 4.2.4, v4.2.5].
Then this:
composer require "phpwhois/phpwhois:~4.0"
which gave the same error as above.
I tried various other syntaxes to specify the version here, but none of them worked.
Any ideas?
Ok, let's start from the beginning.
Download the latest composer.phar from getcomposer.org (scroll down to manual install).
Put it in your project root directory.
Remove all your current require statements from your composer.json.
Open a terminal and navigate to your project root.
Execute php composer.phar require phpwhois/phpwhois.
Execute php composer.phar install.
Include the autoloader in your code: require vendor/autoload.php.

Setting up php-casperjs with composer

I'm having trouble setting up php-casperjs for my project. I've never used composer before, so I'm not exactly sure what I'm doing wrong.
I got xampp installed on Windows with php version 5.6.12
Here are the steps I completed so far.
Downloaded and installed composer. It launches successfully from the command prompt.
Downloaded php-casperjs and extracted composer.json and src/Casper.php into my project folder C:\xampp\htdocs\test
Navigated to the project folder in the command prompt and ran composer install command which installed 22 packages
Then I ran composer require phpcasperjs/phpcasperjs command and here I ran into problems. I get the following error message
Using version ^1.2 for phpcasperjs/phpcasperjs
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package phpcasperjs/phpcasperjs No version set (parsed as 1.0.0) is satisfiable by phpcasperjs/phpcasperjs[No version
set (parsed as 1.0.0)] but these conflict with your requirements or
minimum-stability.
Installation failed, reverting ./composer.json to its original
content.
When I run the following php code
use Browser\Casper;
$casper = new Casper();
I get Fatal error: Class 'Browser\Casper' not found in C:\xampp\htdocs\test\test.php on line 3
Step1: Go to you project directory and create a file "composer.json"
codes for composer.json
{
"require": {
"monolog/monolog": "1.0.*"
}
}
Note: You can create you composer.json with your required packages but i just created a simple composer.json file with monolog/monolog package. For your understanding you can follow my steps (this). You can remove the package monolog later on.
Now navigate to the project directory where composer.json file located
Run the following command:
composer require phpcasperjs/phpcasperjs
And you faced the above problem because of wrong or mismatched version of the intended package. Keep in mind that you always can create composer.json with your custom packages and their versions and which will be your package manager. For more detail about composer please visit Link

Categories